Update README.md
Browse files
README.md
CHANGED
|
@@ -48,11 +48,10 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
| 48 |
torch.random.manual_seed(0)
|
| 49 |
|
| 50 |
model = AutoModelForCausalLM.from_pretrained(
|
| 51 |
-
"OEvortex/EMO-phi-128k",
|
| 52 |
-
device_map="cuda",
|
| 53 |
-
torch_dtype="auto",
|
| 54 |
-
trust_remote_code=True,
|
| 55 |
-
ignore_mismatched_sizes=True
|
| 56 |
)
|
| 57 |
tokenizer = AutoTokenizer.from_pretrained("OEvortex/EMO-phi-128k")
|
| 58 |
|
|
@@ -61,16 +60,6 @@ messages = [
|
|
| 61 |
{"role": "user", "content": "My best friend recently lost their parent to cancer after a long battle. They are understandably devastated and struggling with grief."},
|
| 62 |
]
|
| 63 |
|
| 64 |
-
# Prepare the input for the pipeline
|
| 65 |
-
formatted_messages = ""
|
| 66 |
-
for message in messages:
|
| 67 |
-
formatted_messages += f"<|im_start|>{message['role']}\n{message['content']}<|im_end|>\n"
|
| 68 |
-
|
| 69 |
-
# Optionally, add a generation prompt
|
| 70 |
-
add_generation_prompt = True # Set this to True if you want to add a generation prompt
|
| 71 |
-
if add_generation_prompt:
|
| 72 |
-
formatted_messages += "<|im_start|>assistant\n"
|
| 73 |
-
|
| 74 |
pipe = pipeline(
|
| 75 |
"text-generation",
|
| 76 |
model=model,
|
|
@@ -78,13 +67,14 @@ pipe = pipeline(
|
|
| 78 |
)
|
| 79 |
|
| 80 |
generation_args = {
|
| 81 |
-
"max_new_tokens":
|
| 82 |
"return_full_text": False,
|
| 83 |
"temperature": 0.6,
|
| 84 |
"do_sample": True,
|
| 85 |
}
|
| 86 |
|
| 87 |
-
output = pipe(
|
| 88 |
print(output[0]['generated_text'])
|
| 89 |
|
|
|
|
| 90 |
```
|
|
|
|
| 48 |
torch.random.manual_seed(0)
|
| 49 |
|
| 50 |
model = AutoModelForCausalLM.from_pretrained(
|
| 51 |
+
"OEvortex/EMO-phi-128k",
|
| 52 |
+
device_map="cuda",
|
| 53 |
+
torch_dtype="auto",
|
| 54 |
+
trust_remote_code=True,
|
|
|
|
| 55 |
)
|
| 56 |
tokenizer = AutoTokenizer.from_pretrained("OEvortex/EMO-phi-128k")
|
| 57 |
|
|
|
|
| 60 |
{"role": "user", "content": "My best friend recently lost their parent to cancer after a long battle. They are understandably devastated and struggling with grief."},
|
| 61 |
]
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
pipe = pipeline(
|
| 64 |
"text-generation",
|
| 65 |
model=model,
|
|
|
|
| 67 |
)
|
| 68 |
|
| 69 |
generation_args = {
|
| 70 |
+
"max_new_tokens": 2024,
|
| 71 |
"return_full_text": False,
|
| 72 |
"temperature": 0.6,
|
| 73 |
"do_sample": True,
|
| 74 |
}
|
| 75 |
|
| 76 |
+
output = pipe(messages, **generation_args)
|
| 77 |
print(output[0]['generated_text'])
|
| 78 |
|
| 79 |
+
|
| 80 |
```
|