Shahrokhpk commited on
Commit
dbeca7d
·
verified ·
1 Parent(s): 7b32ea5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -22
app.py CHANGED
@@ -1,25 +1,8 @@
1
- from transformers import AutoModelForCausalLM, AutoTokenizer
2
- device = "cpu" # the device to load the model onto
3
 
4
- model = AutoModelForCausalLM.from_pretrained(
5
- "NTQAI/Nxcode-CQ-7B-orpo",
6
- torch_dtype="auto",
7
- device_map="auto"
8
- )
9
- tokenizer = AutoTokenizer.from_pretrained("NTQAI/Nxcode-CQ-7B-orpo")
10
-
11
- prompt = """Complete the following Python function:
12
- from typing import List
13
-
14
-
15
- def has_close_elements(numbers: List[float], threshold: float) -> bool:
16
-
17
-
18
- """
19
  messages = [
20
- {"role": "user", "content": prompt}
21
  ]
22
-
23
- inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
24
- outputs = model.generate(inputs, max_new_tokens=512, do_sample=True, top_k=50, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
25
- res = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)
 
1
+ # Use a pipeline as a high-level helper
2
+ from transformers import pipeline
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  messages = [
5
+ {"role": "user", "content": "Who are you?"},
6
  ]
7
+ pipe = pipeline("text-generation", model="defog/llama-3-sqlcoder-8b")
8
+ pipe(messages)