sumanthd commited on
Commit
b821413
Β·
1 Parent(s): 721ac91

fix generation

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import torch
2
  import spaces
3
  from collections.abc import Iterator
@@ -9,6 +10,7 @@ MAX_MAX_NEW_TOKENS = 4096
9
  DEFAULT_MAX_NEW_TOKENS = 2048
10
  MAX_INPUT_TOKEN_LENGTH = 4096
11
 
 
12
 
13
  DESCRIPTION = """\
14
  # IndicTrans3-beta πŸš€
@@ -20,8 +22,8 @@ DESCRIPTION = """\
20
 
21
  # if torch.cuda.is_available():
22
  model_id = "ai4bharat/IndicTrans3-beta"
23
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto", offload_folder="offload")
24
- tokenizer = AutoTokenizer.from_pretrained(model_id)
25
 
26
 
27
  LANGUAGES = {
@@ -180,7 +182,7 @@ with gr.Blocks(theme=gr.themes.Default(), css=css) as demo:
180
  gr.Number(value=0.1, visible=False),
181
  gr.Number(value=0.9, visible=False),
182
  gr.Number(value=50, visible=False),
183
- gr.Number(value=0.1, visible=False)
184
  ],
185
  outputs=text_output
186
  )
@@ -197,10 +199,10 @@ with gr.Blocks(theme=gr.themes.Default(), css=css) as demo:
197
  tgt_lang,
198
  text_input,
199
  gr.Number(value=4096, visible=False),
200
- gr.Number(value=0, visible=False),
201
  gr.Number(value=0.9, visible=False),
202
  gr.Number(value=50, visible=False),
203
- gr.Number(value=0.0, visible=False)
204
  ],
205
  outputs=text_output,
206
  fn=generate_for_examples,
 
1
+ import os
2
  import torch
3
  import spaces
4
  from collections.abc import Iterator
 
10
  DEFAULT_MAX_NEW_TOKENS = 2048
11
  MAX_INPUT_TOKEN_LENGTH = 4096
12
 
13
+ HF_TOKEN = os.environ['HF_TOKEN']
14
 
15
  DESCRIPTION = """\
16
  # IndicTrans3-beta πŸš€
 
22
 
23
  # if torch.cuda.is_available():
24
  model_id = "ai4bharat/IndicTrans3-beta"
25
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto", offload_folder="offload", token=HF_TOKEN)
26
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
27
 
28
 
29
  LANGUAGES = {
 
182
  gr.Number(value=0.1, visible=False),
183
  gr.Number(value=0.9, visible=False),
184
  gr.Number(value=50, visible=False),
185
+ gr.Number(value=1.0, visible=False)
186
  ],
187
  outputs=text_output
188
  )
 
199
  tgt_lang,
200
  text_input,
201
  gr.Number(value=4096, visible=False),
202
+ gr.Number(value=0.1, visible=False),
203
  gr.Number(value=0.9, visible=False),
204
  gr.Number(value=50, visible=False),
205
+ gr.Number(value=1.0, visible=False)
206
  ],
207
  outputs=text_output,
208
  fn=generate_for_examples,