Deepesh-001 commited on
Commit
3205dc1
·
verified ·
1 Parent(s): fad73b3

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +31 -0
  2. requirement.txt +3 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+
4
+ # Load your fine-tuned model from Hugging Face Hub
5
+ model_name = "Deepesh-001/RagFin-Ai" # Replace with actual name
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ # Function to generate response from user query + context
10
+ def generate_answer(query, context):
11
+ input_text = f"Context: {context}\n\nQuestion: {query}\nAnswer:"
12
+ inputs = tokenizer(input_text, return_tensors="pt")
13
+ outputs = model.generate(**inputs, max_length=300, do_sample=True, top_k=50)
14
+ answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
15
+ return answer
16
+
17
+ # Gradio UI
18
+ iface = gr.Interface(
19
+ fn=generate_answer,
20
+ inputs=[
21
+ gr.Textbox(label="User Query", placeholder="How can I save tax on ₹15 lakhs income?"),
22
+ gr.Textbox(label="Context", placeholder="Provide some financial context or let it be blank...")
23
+ ],
24
+ outputs="text",
25
+ title="Financial LLM - Indian Tax Advisor",
26
+ description="Ask anything about Indian tax planning, deductions, or financial strategies."
27
+ )
28
+
29
+ # Run the app
30
+ if __name__ == "__main__":
31
+ iface.launch()
requirement.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio