tktung commited on
Commit
a3bff06
1 Parent(s): 90266e3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -0
README.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Run the model
2
+
3
+ ### Instruction format
4
+ The template used to build a prompt for this Instruct model is defined as follows:
5
+
6
+ ```
7
+ ### USER:
8
+ {instruction1}
9
+ ### RESPONSE:
10
+ {respone1}
11
+ ### USER:
12
+ {instruction2}
13
+ ### RESPONSE:
14
+ {respone2}
15
+ ```
16
+
17
+ Run the model with the transformers library:
18
+ ```python
19
+ from transformers import AutoModelForCausalLM, AutoTokenizer
20
+ import torch
21
+ model_id = "tktung/MultiSV_Mixtral-8x7B-v0.1"
22
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
23
+ model = AutoModelForCausalLM.from_pretrained(model_id,
24
+ device_map="auto",
25
+ dtype=torch.float16 # optional, load in 16-bit precision mode to reduce memory usage
26
+ )
27
+ model.eval()
28
+
29
+ def make_prompt(instruction):
30
+ return f"""### USER:
31
+ {instruction}
32
+ ### RESPONSE:
33
+ """
34
+
35
+ user_input = "Känner du till WARA M&L?"
36
+ input_prompt = make_prompt(user_input)
37
+ input_ids = tokenizer(input_prompt, return_tensors="pt")["input_ids"]
38
+ generated_token_ids = model.generate(
39
+ inputs=input_ids,
40
+ max_new_tokens=100,
41
+ do_sample=True,
42
+ temperature=0.6,
43
+ top_p=1,
44
+ )[0]
45
+ generated_text = tokenizer.decode(generated_token_ids)
46
+ ```
47
+
48
+ ### Retrieval Augmented Generation
49
+ The model was trained with the following prompt format for RAG:
50
+
51
+ Vietnamese:
52
+ ```
53
+ ### USER:
54
+ Sử dụng ngữ cảnh sau để trả lời câu hỏi ở cuối:
55
+ {context}
56
+ Câu hỏi: {human_prompt}
57
+ ### RESPONSE:
58
+ ```
59
+
60
+ Swedish:
61
+ ```
62
+ ### USER:
63
+ Använd följande sammanhang för att svara på frågan:
64
+ {context}
65
+ Fråga: {human_prompt}
66
+ ### RESPONSE:
67
+ ```