Spaces:
Running
Running
Dhahlan2000
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -48,11 +48,12 @@ 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 |
|
52 |
-
client = InferenceClient("google/gemma-2b-it")
|
53 |
|
54 |
def conversation_predict(text):
|
55 |
-
return client.text_generation(text, return_full_text=False)
|
56 |
# pipe = pipeline(
|
57 |
# "text-generation",
|
58 |
# model=model,
|
@@ -71,6 +72,9 @@ def conversation_predict(text):
|
|
71 |
# outputs = model.generate(**input_ids)
|
72 |
# return tokenizer.decode(outputs[0])
|
73 |
|
|
|
|
|
|
|
74 |
def ai_predicted(user_input):
|
75 |
if user_input.lower() == 'exit':
|
76 |
return "Goodbye!"
|
|
|
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", torch_dtype=torch.bfloat16, device_map="auto")
|
52 |
|
53 |
+
# client = InferenceClient("google/gemma-2b-it")
|
54 |
|
55 |
def conversation_predict(text):
|
56 |
+
# return client.text_generation(text, return_full_text=False)
|
57 |
# pipe = pipeline(
|
58 |
# "text-generation",
|
59 |
# model=model,
|
|
|
72 |
# outputs = model.generate(**input_ids)
|
73 |
# return tokenizer.decode(outputs[0])
|
74 |
|
75 |
+
outputs = pipe1(text, max_new_tokens=256, do_sample=True, 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':
|
80 |
return "Goodbye!"
|