Update README.md
Browse files
README.md
CHANGED
@@ -16,6 +16,8 @@ language:
|
|
16 |
|
17 |
# How to use
|
18 |
|
|
|
|
|
19 |
```python
|
20 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
21 |
import torch
|
@@ -33,6 +35,28 @@ prompt = tokenizer.apply_chat_template(conversation=messages, add_generation_pro
|
|
33 |
pipe(prompt, max_new_tokens=100, do_sample=False, temperature=0.0, return_full_text=False)
|
34 |
```
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
# Base checkpoint
|
37 |
[lightblue/karasu-7B](https://huggingface.co/lightblue/karasu-7B)
|
38 |
|
|
|
16 |
|
17 |
# How to use
|
18 |
|
19 |
+
|
20 |
+
### Hugggingface
|
21 |
```python
|
22 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
23 |
import torch
|
|
|
35 |
pipe(prompt, max_new_tokens=100, do_sample=False, temperature=0.0, return_full_text=False)
|
36 |
```
|
37 |
|
38 |
+
|
39 |
+
### VLLM
|
40 |
+
```python
|
41 |
+
from vllm import LLM, SamplingParams
|
42 |
+
|
43 |
+
sampling_params = SamplingParams(temperature=0.0, max_tokens=100)
|
44 |
+
llm = LLM(model="lightblue/karasu-7B-chat")
|
45 |
+
|
46 |
+
messages = [{"role": "system", "content": "あなたはAIアシスタントです。"}]
|
47 |
+
messages.append({"role": "user", "content": "イギリスの首相は誰ですか?"})
|
48 |
+
prompt = llm.llm_engine.tokenizer.apply_chat_template(conversation=messages, add_generation_prompt=True, tokenize=False)
|
49 |
+
prompts = [prompt]
|
50 |
+
|
51 |
+
outputs = llm.generate(prompts, sampling_params)
|
52 |
+
for output in outputs:
|
53 |
+
prompt = output.prompt
|
54 |
+
generated_text = output.outputs[0].text
|
55 |
+
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
|
56 |
+
```
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
# Base checkpoint
|
61 |
[lightblue/karasu-7B](https://huggingface.co/lightblue/karasu-7B)
|
62 |
|