Update README.md
Browse files
README.md
CHANGED
|
@@ -28,6 +28,54 @@ __Ring-1T__ remains under continuous training. While the preview version already
|
|
| 28 |
<img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*Q1NZT4ti6aoAAAAAgBAAAAgAemJ7AQ/original"/>
|
| 29 |
<p>
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
## License
|
| 32 |
|
| 33 |
This code repository is licensed under [the MIT License](https://github.com/inclusionAI/Ling-V2/blob/master/LICENCE).
|
|
|
|
| 28 |
<img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*Q1NZT4ti6aoAAAAAgBAAAAgAemJ7AQ/original"/>
|
| 29 |
<p>
|
| 30 |
|
| 31 |
+
|
| 32 |
+
## Quickstart
|
| 33 |
+
|
| 34 |
+
### 🤗 Hugging Face Transformers
|
| 35 |
+
|
| 36 |
+
Here is a code snippet to show you how to use the chat model with `transformers`:
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 40 |
+
|
| 41 |
+
model_name = "inclusionAI/Ring-1T-preview"
|
| 42 |
+
|
| 43 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 44 |
+
model_name,
|
| 45 |
+
dtype="auto",
|
| 46 |
+
device_map="auto",
|
| 47 |
+
trust_remote_code=True,
|
| 48 |
+
)
|
| 49 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 50 |
+
|
| 51 |
+
prompt = "Give me a short introduction to large language models."
|
| 52 |
+
messages = [
|
| 53 |
+
{"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
|
| 54 |
+
{"role": "user", "content": prompt}
|
| 55 |
+
]
|
| 56 |
+
text = tokenizer.apply_chat_template(
|
| 57 |
+
messages,
|
| 58 |
+
tokenize=False,
|
| 59 |
+
add_generation_prompt=True
|
| 60 |
+
)
|
| 61 |
+
model_inputs = tokenizer([text], return_tensors="pt", return_token_type_ids=False).to(model.device)
|
| 62 |
+
|
| 63 |
+
generated_ids = model.generate(
|
| 64 |
+
**model_inputs,
|
| 65 |
+
max_new_tokens=8192
|
| 66 |
+
)
|
| 67 |
+
generated_ids = [
|
| 68 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 69 |
+
]
|
| 70 |
+
|
| 71 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
### 🤖 ModelScope
|
| 75 |
+
|
| 76 |
+
If you're in mainland China, we strongly recommend you to use our model from 🤖 <a href="https://modelscope.cn/organization/inclusionAI">ModelScope</a>.
|
| 77 |
+
|
| 78 |
+
|
| 79 |
## License
|
| 80 |
|
| 81 |
This code repository is licensed under [the MIT License](https://github.com/inclusionAI/Ling-V2/blob/master/LICENCE).
|