Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +2 -16
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,31 +1,17 @@
|
|
1 |
-
import os
|
2 |
from fastapi import FastAPI
|
3 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
4 |
from peft import PeftModel, PeftConfig
|
5 |
-
from huggingface_hub import login
|
6 |
-
from dotenv import load_dotenv
|
7 |
-
|
8 |
-
# Load environment variables from .env file
|
9 |
-
load_dotenv()
|
10 |
-
|
11 |
-
# Get the Hugging Face token from the environment variable
|
12 |
-
huggingface_token = os.getenv("HUGGING_FACE_TOKEN")
|
13 |
-
if huggingface_token is None:
|
14 |
-
raise ValueError("HUGGING_FACE_TOKEN environment variable is not set")
|
15 |
-
|
16 |
-
# Login to Hugging Face Hub
|
17 |
-
login(token=huggingface_token)
|
18 |
|
19 |
# Initialize FastAPI app
|
20 |
app = FastAPI()
|
21 |
|
22 |
# Load PEFT model configuration and base model
|
23 |
config = PeftConfig.from_pretrained("frankmorales2020/Mistral-7B-text-to-sql-flash-attention-2-dataeval")
|
24 |
-
base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3"
|
25 |
model = PeftModel.from_pretrained(base_model, "frankmorales2020/Mistral-7B-text-to-sql-flash-attention-2-dataeval")
|
26 |
|
27 |
# Load tokenizer
|
28 |
-
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3"
|
29 |
|
30 |
# Create the pipeline
|
31 |
pipe = pipeline("text2sql", model=model, tokenizer=tokenizer)
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
3 |
from peft import PeftModel, PeftConfig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Initialize FastAPI app
|
6 |
app = FastAPI()
|
7 |
|
8 |
# Load PEFT model configuration and base model
|
9 |
config = PeftConfig.from_pretrained("frankmorales2020/Mistral-7B-text-to-sql-flash-attention-2-dataeval")
|
10 |
+
base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3")
|
11 |
model = PeftModel.from_pretrained(base_model, "frankmorales2020/Mistral-7B-text-to-sql-flash-attention-2-dataeval")
|
12 |
|
13 |
# Load tokenizer
|
14 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3")
|
15 |
|
16 |
# Create the pipeline
|
17 |
pipe = pipeline("text2sql", model=model, tokenizer=tokenizer)
|
requirements.txt
CHANGED
@@ -7,4 +7,4 @@ transformers==4.*
|
|
7 |
numpy<2
|
8 |
peft==0.11.1
|
9 |
huggingface-hub>=0.17.0
|
10 |
-
|
|
|
7 |
numpy<2
|
8 |
peft==0.11.1
|
9 |
huggingface-hub>=0.17.0
|
10 |
+
|