Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,26 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
model_identifier = "curiouscurrent/omnicode"
|
| 6 |
-
model = AutoModelForCausalLM.from_pretrained(model_identifier)
|
| 7 |
-
tokenizer = AutoTokenizer.from_pretrained(model_identifier)
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
# Create Gradio interface
|
| 25 |
-
input_prompt = gr.inputs.Textbox(lines=4, label="Input Prompt")
|
| 26 |
-
output_text = gr.outputs.Textbox(label="Response")
|
| 27 |
-
|
| 28 |
-
gr.Interface(
|
| 29 |
-
generate_response,
|
| 30 |
-
inputs=input_prompt,
|
| 31 |
-
outputs=output_text,
|
| 32 |
-
title="OmniCode",
|
| 33 |
-
description="Multi programming coding assistant",
|
| 34 |
-
theme="compact"
|
| 35 |
-
).launch()
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer
|
| 2 |
+
import transformers
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
model = "codellama/CodeLlama-7b-hf"
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
| 8 |
+
pipeline = transformers.pipeline(
|
| 9 |
+
"text-generation",
|
| 10 |
+
model=model,
|
| 11 |
+
torch_dtype=torch.float16,
|
| 12 |
+
device_map="auto",
|
| 13 |
+
)
|
| 14 |
|
| 15 |
+
sequences = pipeline(
|
| 16 |
+
'import socket\n\ndef ping_exponential_backoff(host: str):',
|
| 17 |
+
do_sample=True,
|
| 18 |
+
top_k=10,
|
| 19 |
+
temperature=0.1,
|
| 20 |
+
top_p=0.95,
|
| 21 |
+
num_return_sequences=1,
|
| 22 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 23 |
+
max_length=200,
|
| 24 |
+
)
|
| 25 |
+
for seq in sequences:
|
| 26 |
+
print(f"Result: {seq['generated_text']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|