Nucha commited on
Commit
b967231
·
verified ·
1 Parent(s): 78f1e83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -1,10 +1,10 @@
1
- from transformers import AutoTokenizer, AutoModelForCausalLM
2
- tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-instruct", trust_remote_code=True)
3
- model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-instruct", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
4
- messages=[
5
- { 'role': 'user', 'content': "write a quick sort algorithm in python."}
6
- ]
7
- inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
8
- # tokenizer.eos_token_id is the id of <|EOT|> token
9
- outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
10
- print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
 
1
+ import transformers
2
+ import torch
3
+
4
+ model_id = "meta-llama/Llama-3.1-8B"
5
+
6
+ pipeline = transformers.pipeline(
7
+ "text-generation", model=model_id, model_kwargs={"torch_dtype": torch.bfloat16}, device_map="auto"
8
+ )
9
+
10
+ pipeline("Hey how are you doing today?")