Update README.md
Browse files
README.md
CHANGED
|
@@ -45,13 +45,19 @@ The model supports English language.
|
|
| 45 |
|
| 46 |
## Usage
|
| 47 |
|
| 48 |
-
# CPU
|
| 49 |
|
| 50 |
```python
|
| 51 |
from transformers import pipeline
|
|
|
|
| 52 |
|
| 53 |
-
|
|
|
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
messages = [
|
| 56 |
{
|
| 57 |
"role": "system",
|
|
@@ -63,7 +69,13 @@ messages = [
|
|
| 63 |
},
|
| 64 |
]
|
| 65 |
|
|
|
|
| 66 |
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
|
|
|
|
|
|
| 67 |
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
|
|
|
|
|
|
| 68 |
print(outputs[0]["generated_text"])
|
|
|
|
| 69 |
```
|
|
|
|
| 45 |
|
| 46 |
## Usage
|
| 47 |
|
| 48 |
+
# CPU and GPU code
|
| 49 |
|
| 50 |
```python
|
| 51 |
from transformers import pipeline
|
| 52 |
+
from accelerate import Accelerator
|
| 53 |
|
| 54 |
+
# Initialize the accelerator
|
| 55 |
+
accelerator = Accelerator()
|
| 56 |
|
| 57 |
+
# Initialize the pipeline
|
| 58 |
+
pipe = pipeline("text-generation", model="OEvortex/HelpingAI-Lite", device=accelerator.device)
|
| 59 |
+
|
| 60 |
+
# Define the messages
|
| 61 |
messages = [
|
| 62 |
{
|
| 63 |
"role": "system",
|
|
|
|
| 69 |
},
|
| 70 |
]
|
| 71 |
|
| 72 |
+
# Prepare the prompt
|
| 73 |
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 74 |
+
|
| 75 |
+
# Generate predictions
|
| 76 |
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
| 77 |
+
|
| 78 |
+
# Print the generated text
|
| 79 |
print(outputs[0]["generated_text"])
|
| 80 |
+
|
| 81 |
```
|