Spaces:
Runtime error
Runtime error
update app
Browse files- app.py +30 -3
- requirements.txt +75 -0
app.py
CHANGED
|
@@ -1,9 +1,36 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def greet(name):
|
| 5 |
-
return "Hello " + name + "!!"
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
DEVICE = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
| 6 |
+
MODEL_ID = "LinguaCustodia/ClassiFin"
|
| 7 |
+
TOKENIZER_ID = "Snowflake/snowflake-arctic-embed-m"
|
| 8 |
+
MODEL = AutoModelForSequenceClassification.from_pretrained(MODEL_ID).to(DEVICE)
|
| 9 |
+
TOKENIZER = AutoTokenizer.from_pretrained(TOKENIZER_ID)
|
| 10 |
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
def classify(text):
|
| 13 |
+
inputs = TOKENIZER(text, return_tensors="pt")
|
| 14 |
+
for k, v in inputs.items():
|
| 15 |
+
inputs[k] = v.to(DEVICE)
|
| 16 |
|
| 17 |
+
outputs = MODEL(**inputs)
|
| 18 |
+
logits = outputs.logits.cpu().clamp(min=0.0, max=1.0).squeeze().item()
|
| 19 |
+
return {
|
| 20 |
+
"finance": logits,
|
| 21 |
+
"not finance": 1.0 - logits,
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
EXAMPLES = [
|
| 26 |
+
'A call option, often simply labeled a "call", is a contract between the buyer and the seller of the call option to exchange a security at a set price.',
|
| 27 |
+
"Natural language processing (NLP) is a subfield of computer science and especially artificial intelligence. It is primarily concerned with providing computers with the ability to process data encoded in natural language and is thus closely related to information retrieval, knowledge representation and computational linguistics, a subfield of linguistics.",
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
demo = gr.Interface(
|
| 31 |
+
fn=classify,
|
| 32 |
+
inputs=gr.Textbox(lines=3),
|
| 33 |
+
examples=EXAMPLES,
|
| 34 |
+
outputs=gr.Label(),
|
| 35 |
+
)
|
| 36 |
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==23.2.1
|
| 2 |
+
annotated-types==0.7.0
|
| 3 |
+
anyio==4.8.0
|
| 4 |
+
certifi==2025.1.31
|
| 5 |
+
charset-normalizer==3.4.1
|
| 6 |
+
click==8.1.8
|
| 7 |
+
fastapi==0.115.11
|
| 8 |
+
ffmpy==0.5.0
|
| 9 |
+
filelock==3.17.0
|
| 10 |
+
fsspec==2025.3.0
|
| 11 |
+
gradio==5.20.1
|
| 12 |
+
gradio-client==1.7.2
|
| 13 |
+
groovy==0.1.2
|
| 14 |
+
h11==0.14.0
|
| 15 |
+
httpcore==1.0.7
|
| 16 |
+
httpx==0.28.1
|
| 17 |
+
huggingface-hub==0.29.3
|
| 18 |
+
idna==3.10
|
| 19 |
+
jinja2==3.1.6
|
| 20 |
+
markdown-it-py==3.0.0
|
| 21 |
+
markupsafe==2.1.5
|
| 22 |
+
mdurl==0.1.2
|
| 23 |
+
mpmath==1.3.0
|
| 24 |
+
networkx==3.4.2
|
| 25 |
+
numpy==2.2.3
|
| 26 |
+
nvidia-cublas-cu12==12.4.5.8
|
| 27 |
+
nvidia-cuda-cupti-cu12==12.4.127
|
| 28 |
+
nvidia-cuda-nvrtc-cu12==12.4.127
|
| 29 |
+
nvidia-cuda-runtime-cu12==12.4.127
|
| 30 |
+
nvidia-cudnn-cu12==9.1.0.70
|
| 31 |
+
nvidia-cufft-cu12==11.2.1.3
|
| 32 |
+
nvidia-curand-cu12==10.3.5.147
|
| 33 |
+
nvidia-cusolver-cu12==11.6.1.9
|
| 34 |
+
nvidia-cusparse-cu12==12.3.1.170
|
| 35 |
+
nvidia-cusparselt-cu12==0.6.2
|
| 36 |
+
nvidia-nccl-cu12==2.21.5
|
| 37 |
+
nvidia-nvjitlink-cu12==12.4.127
|
| 38 |
+
nvidia-nvtx-cu12==12.4.127
|
| 39 |
+
orjson==3.10.15
|
| 40 |
+
packaging==24.2
|
| 41 |
+
pandas==2.2.3
|
| 42 |
+
pillow==11.1.0
|
| 43 |
+
pydantic==2.10.6
|
| 44 |
+
pydantic-core==2.27.2
|
| 45 |
+
pydub==0.25.1
|
| 46 |
+
pygments==2.19.1
|
| 47 |
+
python-dateutil==2.9.0.post0
|
| 48 |
+
python-multipart==0.0.20
|
| 49 |
+
pytz==2025.1
|
| 50 |
+
pyyaml==6.0.2
|
| 51 |
+
regex==2024.11.6
|
| 52 |
+
requests==2.32.3
|
| 53 |
+
rich==13.9.4
|
| 54 |
+
ruff==0.9.10
|
| 55 |
+
safehttpx==0.1.6
|
| 56 |
+
safetensors==0.5.3
|
| 57 |
+
semantic-version==2.10.0
|
| 58 |
+
setuptools==76.0.0
|
| 59 |
+
shellingham==1.5.4
|
| 60 |
+
six==1.17.0
|
| 61 |
+
sniffio==1.3.1
|
| 62 |
+
starlette==0.46.1
|
| 63 |
+
sympy==1.13.1
|
| 64 |
+
tokenizers==0.21.1
|
| 65 |
+
tomlkit==0.13.2
|
| 66 |
+
torch==2.6.0
|
| 67 |
+
tqdm==4.67.1
|
| 68 |
+
transformers==4.49.0
|
| 69 |
+
triton==3.2.0
|
| 70 |
+
typer==0.15.2
|
| 71 |
+
typing-extensions==4.12.2
|
| 72 |
+
tzdata==2025.1
|
| 73 |
+
urllib3==2.3.0
|
| 74 |
+
uvicorn==0.34.0
|
| 75 |
+
websockets==15.0.1
|