huriacane33 commited on
Commit
4d8d534
·
verified ·
1 Parent(s): 1a3cbfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -3,13 +3,17 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
  import pandas as pd
4
  import re
5
 
6
- # Load the Falcon-7B-Instruct model and tokenizer
7
  @st.cache_resource
8
  def load_falcon_model():
9
- """Load the Falcon-7B-Instruct model and tokenizer."""
10
- model_name = "tiiuae/falcon-7b-instruct" # Open model for instruction-based tasks
11
  tokenizer = AutoTokenizer.from_pretrained(model_name)
12
- model = AutoModelForCausalLM.from_pretrained(model_name)
 
 
 
 
13
  return pipeline("text-generation", model=model, tokenizer=tokenizer)
14
 
15
  qa_pipeline = load_falcon_model()
 
3
  import pandas as pd
4
  import re
5
 
6
+ # Load the Falcon-3B-Instruct model and tokenizer
7
  @st.cache_resource
8
  def load_falcon_model():
9
+ """Load the Falcon-3B-Instruct model and tokenizer."""
10
+ model_name = "tiiuae/falcon-3b-instruct" # Smaller model for faster loading
11
  tokenizer = AutoTokenizer.from_pretrained(model_name)
12
+ model = AutoModelForCausalLM.from_pretrained(
13
+ model_name,
14
+ torch_dtype="auto", # Use FP16 if supported
15
+ device_map="auto" # Automatically distributes across available devices
16
+ )
17
  return pipeline("text-generation", model=model, tokenizer=tokenizer)
18
 
19
  qa_pipeline = load_falcon_model()