moamen270 commited on
Commit
e94aab2
·
1 Parent(s): 855b075

Update endpoints.py

Browse files
Files changed (1) hide show
  1. endpoints.py +16 -18
endpoints.py CHANGED
@@ -13,24 +13,22 @@ import requests
13
  # response = requests.post(API_URL, headers=headers, json=payload)
14
  # return response.json()
15
 
16
- # def LLM(llm_name, length):
17
- # print(llm_name)
18
- # tokenizer = AutoTokenizer.from_pretrained(llm_name)
19
- # model = AutoModelForCausalLM.from_pretrained(llm_name)
20
- # pipe = pipeline("text-generation",
21
- # model=model,
22
- # tokenizer=tokenizer,
23
- # max_length=length,
24
- # do_sample=True,
25
- # top_p=0.95,
26
- # repetition_penalty=1.2,
27
- # )
28
- # return pipe
29
- # Load model directly
30
- # Use a pipeline as a high-level helper
31
- from transformers import pipeline
32
-
33
- pipe = pipeline("text-generation", model="codellama/CodeLlama-7b-hf")
34
 
35
  # tokenizer = AutoTokenizer.from_pretrained("WizardLM/WizardCoder-1B-V1.0")
36
  # base_model = AutoModelForCausalLM.from_pretrained("WizardLM/WizardCoder-1B-V1.0")
 
13
  # response = requests.post(API_URL, headers=headers, json=payload)
14
  # return response.json()
15
 
16
+ def LLM(llm_name, length):
17
+ print(llm_name)
18
+ tokenizer = AutoTokenizer.from_pretrained(llm_name)
19
+ model = AutoModelForCausalLM.from_pretrained(llm_name)
20
+ pipe = pipeline("text-generation",
21
+ model=model,
22
+ tokenizer=tokenizer,
23
+ max_length=length,
24
+ do_sample=True,
25
+ top_p=0.95,
26
+ repetition_penalty=1.2,
27
+ )
28
+ return pipe
29
+
30
+
31
+ pipe = LLM("codellama/CodeLlama-7b-hf",4000)
 
 
32
 
33
  # tokenizer = AutoTokenizer.from_pretrained("WizardLM/WizardCoder-1B-V1.0")
34
  # base_model = AutoModelForCausalLM.from_pretrained("WizardLM/WizardCoder-1B-V1.0")