Spaces:
Paused
Paused
Update endpoints.py
Browse files- 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 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 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")
|