Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,7 +48,20 @@ def transliterate_to_sinhala(text):
|
|
48 |
# conv_model_name = "microsoft/Phi-3-mini-4k-instruct" # Use GPT-2 instead of the gated model
|
49 |
# tokenizer = AutoTokenizer.from_pretrained(conv_model_name, trust_remote_code=True)
|
50 |
# model = AutoModelForCausalLM.from_pretrained(conv_model_name, trust_remote_code=True).to(device)
|
51 |
-
pipe1 = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0").to(device)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
# client = InferenceClient("google/gemma-2b-it")
|
54 |
|
@@ -72,8 +85,19 @@ def conversation_predict(text):
|
|
72 |
# outputs = model.generate(**input_ids)
|
73 |
# return tokenizer.decode(outputs[0])
|
74 |
|
75 |
-
outputs = pipe1(text, max_new_tokens=256, temperature=0.7, top_k=50, top_p=0.95)
|
76 |
-
return outputs[0]["generated_text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
def ai_predicted(user_input):
|
79 |
if user_input.lower() == 'exit':
|
|
|
48 |
# conv_model_name = "microsoft/Phi-3-mini-4k-instruct" # Use GPT-2 instead of the gated model
|
49 |
# tokenizer = AutoTokenizer.from_pretrained(conv_model_name, trust_remote_code=True)
|
50 |
# model = AutoModelForCausalLM.from_pretrained(conv_model_name, trust_remote_code=True).to(device)
|
51 |
+
# pipe1 = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0").to(device)
|
52 |
+
|
53 |
+
model = "tiiuae/falcon-7b-instruct"
|
54 |
+
|
55 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
56 |
+
text_gen_pipeline = transformers.pipeline(
|
57 |
+
"text-generation",
|
58 |
+
model=model,
|
59 |
+
tokenizer=tokenizer,
|
60 |
+
torch_dtype=torch.bfloat16,
|
61 |
+
trust_remote_code=True,
|
62 |
+
device_map="auto",
|
63 |
+
)
|
64 |
+
|
65 |
|
66 |
# client = InferenceClient("google/gemma-2b-it")
|
67 |
|
|
|
85 |
# outputs = model.generate(**input_ids)
|
86 |
# return tokenizer.decode(outputs[0])
|
87 |
|
88 |
+
# outputs = pipe1(text, max_new_tokens=256, temperature=0.7, top_k=50, top_p=0.95)
|
89 |
+
# return outputs[0]["generated_text"]
|
90 |
+
|
91 |
+
sequences = text_gen_pipeline(
|
92 |
+
text,
|
93 |
+
max_length=200,
|
94 |
+
do_sample=True,
|
95 |
+
top_k=10,
|
96 |
+
num_return_sequences=1,
|
97 |
+
eos_token_id=tokenizer.eos_token_id,
|
98 |
+
)
|
99 |
+
return sequences[0]['generated_text']
|
100 |
+
|
101 |
|
102 |
def ai_predicted(user_input):
|
103 |
if user_input.lower() == 'exit':
|