cicdatopea
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -311,49 +311,6 @@ prompt = "Please give a brief introduction of DeepSeek company."
|
|
311 |
"""DeepSeek Artificial Intelligence Co., Ltd. (referred to as "DeepSeek" or "深度求索") , founded in 2023, is a Chinese company dedicated to making AGI a reality"""
|
312 |
~~~
|
313 |
|
314 |
-
### INT4 Inference on CUDA(have not tested, maybe need 8X80G GPU)
|
315 |
-
|
316 |
-
Int4 kernel with BF16 computing dtype is required.
|
317 |
-
|
318 |
-
````python
|
319 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
320 |
-
import torch
|
321 |
-
quantized_model_dir = "OPEA/DeepSeek-V3-int4-sym-gptq-inc-preview"
|
322 |
-
|
323 |
-
model = AutoModelForCausalLM.from_pretrained(
|
324 |
-
quantized_model_dir,
|
325 |
-
torch_dtype=torch.float16,
|
326 |
-
trust_remote_code=True,
|
327 |
-
device_map="auto"
|
328 |
-
|
329 |
-
)
|
330 |
-
|
331 |
-
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir,trust_remote_code=True)
|
332 |
-
prompt = "There is a girl who likes adventure,"
|
333 |
-
messages = [
|
334 |
-
{"role": "system", "content": "You are a helpful assistant."},
|
335 |
-
{"role": "user", "content": prompt}
|
336 |
-
]
|
337 |
-
text = tokenizer.apply_chat_template(
|
338 |
-
messages,
|
339 |
-
tokenize=False,
|
340 |
-
add_generation_prompt=True
|
341 |
-
)
|
342 |
-
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
343 |
-
|
344 |
-
generated_ids = model.generate(
|
345 |
-
model_inputs.input_ids,
|
346 |
-
max_new_tokens=200, ##change this to align with the official usage
|
347 |
-
do_sample=False ##change this to align with the official usage
|
348 |
-
)
|
349 |
-
generated_ids = [
|
350 |
-
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
351 |
-
]
|
352 |
-
|
353 |
-
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
354 |
-
print(response)
|
355 |
-
|
356 |
-
````
|
357 |
|
358 |
### Evaluate the model
|
359 |
|
|
|
311 |
"""DeepSeek Artificial Intelligence Co., Ltd. (referred to as "DeepSeek" or "深度求索") , founded in 2023, is a Chinese company dedicated to making AGI a reality"""
|
312 |
~~~
|
313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
### Evaluate the model
|
316 |
|