soufyane edderyouch commited on
Commit
1820c53
1 Parent(s): e9a6ac3

Update app.py (#2)

Browse files

- Update app.py (d558110697e74f2f98baead1b567ec5951638043)


Co-authored-by: MOHAMED ED-DERYOUCH <[email protected]>

Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -1,19 +1,20 @@
1
- from transformers import pipeline
 
 
 
 
2
 
3
- # Load the model
4
- model_name = "soufyane/gemma_data_science"
5
- text_generator = pipeline("text-generation", model=model_name)
6
 
7
  def process_text_gemma(input_text):
8
- # Generate text using the model
9
- response = text_generator(f"question: {input_text}", max_length=256)[0]['generated_text']
10
  return response
11
 
 
12
  def main(input_text):
13
  return process_text_gemma(input_text[0])
14
 
15
- import gradio as gr
16
-
17
  gr.Interface(
18
  fn=main,
19
  inputs=["text"],
@@ -21,4 +22,4 @@ gr.Interface(
21
  title="Gemma Data Science Model",
22
  description="This is a text-to-text model for data science tasks.",
23
  live=True
24
- ).launch()
 
1
+ import keras_nlp
2
+ from keras_nlp.models import GemmaCausalLM
3
+ import warnings
4
+ warnings.filterwarnings('ignore')
5
+ import os
6
 
7
+
8
+ model = keras_nlp.models.CausalLM.from_preset(f"hf://soufyane/gemma_data_science")
 
9
 
10
  def process_text_gemma(input_text):
11
+ response = model.generate(f"question: {input_text}", max_length=256)
 
12
  return response
13
 
14
+
15
  def main(input_text):
16
  return process_text_gemma(input_text[0])
17
 
 
 
18
  gr.Interface(
19
  fn=main,
20
  inputs=["text"],
 
22
  title="Gemma Data Science Model",
23
  description="This is a text-to-text model for data science tasks.",
24
  live=True
25
+ ).launch()