alakxender commited on
Commit
cb39169
1 Parent(s): 32dcc58
Files changed (4) hide show
  1. .gitignore +1 -0
  2. README.md +2 -2
  3. app.py +43 -4
  4. requirements.txt +2 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ hf_cache
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Alpaca Lora
3
  emoji: 🦀
4
  colorFrom: gray
5
  colorTo: gray
@@ -7,7 +7,7 @@ sdk: gradio
7
  sdk_version: 5.6.0
8
  app_file: app.py
9
  pinned: false
10
- short_description: alpaca lora test
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Text-Gen Goldfish Models
3
  emoji: 🦀
4
  colorFrom: gray
5
  colorTo: gray
 
7
  sdk_version: 5.6.0
8
  app_file: app.py
9
  pinned: false
10
+ short_description: goldfish-models/div_thaa_full demo
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,7 +1,46 @@
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import necessary libraries
2
+ import torch
3
+ from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM, pipeline
4
  import gradio as gr
5
 
6
+ # Load Goldfish model for Dhivehi
7
+ language = 'Dhivehi'
8
 
9
+ # Load model
10
+ goldfish_model = 'goldfish-models/div_thaa_full'
11
+ config = AutoConfig.from_pretrained(goldfish_model)
12
+ tokenizer = AutoTokenizer.from_pretrained(goldfish_model)
13
+ model = AutoModelForCausalLM.from_pretrained(goldfish_model, config=config)
14
+ if torch.cuda.is_available():
15
+ model = model.cuda() # Load onto GPU
16
+
17
+ # Create text generation pipeline
18
+ text_generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
19
+
20
+ # Function to generate text
21
+ def generate_text(input_text):
22
+ output = text_generator(input_text, max_new_tokens=25, add_special_tokens=False, do_sample=True)
23
+ return output[0]['generated_text']
24
+
25
+ # Create Gradio interface
26
+
27
+ styles = """
28
+ .thaana textarea {
29
+ font-size: 18px !important;
30
+ font-family: 'MV_Faseyha', 'Faruma', 'A_Faruma', 'Noto Sans Thaana', 'MV Boli';
31
+ line-height: 1.8 !important;
32
+ }
33
+ """
34
+
35
+ demo = gr.Interface(
36
+ fn=generate_text,
37
+ css=styles,
38
+ inputs=gr.Textbox(lines=2, label="Enter Dhivehi Text", rtl=True, elem_classes="thaana"),
39
+ outputs=gr.Textbox(lines=2, rtl=True, elem_classes="thaana"),
40
+ title="Demo Dhivehi Text Generator",
41
+ description="Generate text in Dhivehi language. This model is trained to generate coherent text based on the input prompt.",
42
+ article="<p>Model: Goldfish is a suite of monolingual language models trained for 350 languages. This model is the Dhivehi (Thaana script). For more details, visit the <a href='https://github.com/tylerachang/goldfish' target='_blank'>Goldfish Models GitHub repository</a>.</p>"
43
+ )
44
+
45
+ # Launch the app
46
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch
2
+ transformers