SHASWATSINGH3101 commited on
Commit
adb630e
1 Parent(s): c618b6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -5,21 +5,17 @@ import numpy as np
5
  import gradio as gr
6
  from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
7
 
8
- # Set the cache directory
9
- os.environ['TRANSFORMERS_CACHE'] = '/app/.cache'
10
 
11
  # Load the base model with device_map set to 'auto'
12
  model = AutoModelForCausalLM.from_pretrained(
13
  "SHASWATSINGH3101/Qwen2-0.5B-Instruct_lora_merge",
14
- device_map='auto',
15
- cache_dir='/app/.cache'
16
  )
17
 
18
  # Load the tokenizer
19
- tokenizer = AutoTokenizer.from_pretrained(
20
- "SHASWATSINGH3101/Qwen2-0.5B-Instruct_lora_merge",
21
- cache_dir='/app/.cache'
22
- )
23
  tokenizer.pad_token = tokenizer.eos_token
24
 
25
  def gen(model, p, maxlen=100, sample=True):
@@ -49,7 +45,8 @@ iface = gr.Interface(
49
  inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
50
  outputs="text",
51
  title="Legal Letter Generator",
52
- description="Generate a letter informing someone of potential legal action due to a dispute or violation."
 
53
  )
54
 
55
  # Launch the app
 
5
  import gradio as gr
6
  from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
7
 
8
+ # Set the Hugging Face home directory
9
+ os.environ['HF_HOME'] = '/app/.cache'
10
 
11
  # Load the base model with device_map set to 'auto'
12
  model = AutoModelForCausalLM.from_pretrained(
13
  "SHASWATSINGH3101/Qwen2-0.5B-Instruct_lora_merge",
14
+ device_map='auto'
 
15
  )
16
 
17
  # Load the tokenizer
18
+ tokenizer = AutoTokenizer.from_pretrained("SHASWATSINGH3101/Qwen2-0.5B-Instruct_lora_merge")
 
 
 
19
  tokenizer.pad_token = tokenizer.eos_token
20
 
21
  def gen(model, p, maxlen=100, sample=True):
 
45
  inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
46
  outputs="text",
47
  title="Legal Letter Generator",
48
+ description="Generate a letter informing someone of potential legal action due to a dispute or violation.",
49
+ flagging_dir="/app/flagged" # Set the flagging directory
50
  )
51
 
52
  # Launch the app