Update README.md
Browse files
README.md
CHANGED
@@ -39,20 +39,67 @@ If you would like to learn more about the Machine_Mindset open-source model, we
|
|
39 |
* CUDA 11.4 and above are recommended (this is for GPU users, flash-attention users, etc.)
|
40 |
<br>
|
41 |
|
42 |
-
### Dependency
|
43 |
-
|
44 |
-
|
45 |
<br>
|
46 |
|
47 |
### Quickstart
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
* Use LLaMA-Factory (multi-round conversation)
|
50 |
```bash
|
51 |
git clone https://github.com/hiyouga/LLaMA-Factory.git
|
52 |
cd LLaMA-Factory
|
53 |
python ./src/cli_demo.py \
|
54 |
--model_name_or_path /path_to_your_local_model \
|
55 |
-
--template
|
56 |
```
|
57 |
```python
|
58 |
#Conversation records:
|
|
|
39 |
* CUDA 11.4 and above are recommended (this is for GPU users, flash-attention users, etc.)
|
40 |
<br>
|
41 |
|
|
|
|
|
|
|
42 |
<br>
|
43 |
|
44 |
### Quickstart
|
45 |
|
46 |
+
* Using the HuggingFace Transformers library (single-turn dialogue):
|
47 |
+
```bash
|
48 |
+
import torch
|
49 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
50 |
+
from transformers.generation.utils import GenerationConfig
|
51 |
+
|
52 |
+
tokenizer = AutoTokenizer.from_pretrained("FarReelAILab/Machine_Mindset_en_ENFP", use_fast=False, trust_remote_code=True)
|
53 |
+
model = AutoModelForCausalLM.from_pretrained("FarReelAILab/Machine_Mindset_en_ENFP", device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
|
54 |
+
model.generation_config = GenerationConfig.from_pretrained("FarReelAILab/Machine_Mindset_en_ENFP")
|
55 |
+
|
56 |
+
messages = []
|
57 |
+
messages.append({"role": "user", "content": "What is your MBTI personality type?"})
|
58 |
+
response = model.chat(tokenizer, messages)
|
59 |
+
print(response)
|
60 |
+
|
61 |
+
messages.append({'role': 'assistant', 'content': response})
|
62 |
+
messages.append({"role": "user", "content": "After spending a day with a group of people, how do you feel when you return home?"})
|
63 |
+
response = model.chat(tokenizer, messages)
|
64 |
+
print(response)
|
65 |
+
|
66 |
+
```
|
67 |
+
```python
|
68 |
+
|
69 |
+
* Using the HuggingFace Transformers library (multi-turn dialogue):
|
70 |
+
```bash
|
71 |
+
import torch
|
72 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
73 |
+
from transformers.generation.utils import GenerationConfig
|
74 |
+
tokenizer = AutoTokenizer.from_pretrained("FarReelAILab/Machine_Mindset_en_ENFP", use_fast=False, trust_remote_code=True)
|
75 |
+
model = AutoModelForCausalLM.from_pretrained("FarReelAILab/Machine_Mindset_en_ENFP", device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
|
76 |
+
model.generation_config = GenerationConfig.from_pretrained("FarReelAILab/Machine_Mindset_en_ENFP")
|
77 |
+
messages = []
|
78 |
+
print("####Enter 'exit' to exit.")
|
79 |
+
print("####Enter 'clear' to clear the chat history.")
|
80 |
+
while True:
|
81 |
+
user=str(input("User:"))
|
82 |
+
if user.strip()=="exit":
|
83 |
+
break
|
84 |
+
elif user.strip()=="clear":
|
85 |
+
messages=[]
|
86 |
+
continue
|
87 |
+
messages.append({"role": "user", "content": user})
|
88 |
+
response = model.chat(tokenizer, messages)
|
89 |
+
print("Assistant:", response)
|
90 |
+
messages.append({"role": "assistant", "content": str(response)})
|
91 |
+
|
92 |
+
```
|
93 |
+
```python
|
94 |
+
|
95 |
+
|
96 |
* Use LLaMA-Factory (multi-round conversation)
|
97 |
```bash
|
98 |
git clone https://github.com/hiyouga/LLaMA-Factory.git
|
99 |
cd LLaMA-Factory
|
100 |
python ./src/cli_demo.py \
|
101 |
--model_name_or_path /path_to_your_local_model \
|
102 |
+
--template llama2
|
103 |
```
|
104 |
```python
|
105 |
#Conversation records:
|