Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoModel, AutoTokenizer
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Title for your app
|
6 |
+
st.title("Llama-3-8B-Physics Master - Model Inference")
|
7 |
+
|
8 |
+
# Load the model and tokenizer from Hugging Face
|
9 |
+
@st.cache_resource
|
10 |
+
def load_model():
|
11 |
+
model = AutoModel.from_pretrained("gallen881/Llama-3-8B-Physics_Master-GGUF")
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("gallen881/Llama-3-8B-Physics_Master-GGUF")
|
13 |
+
return model, tokenizer
|
14 |
+
|
15 |
+
# Load the model once and store it in cache
|
16 |
+
model, tokenizer = load_model()
|
17 |
+
|
18 |
+
# Text input for the user
|
19 |
+
user_input = st.text_area("Enter your input here:")
|
20 |
+
|
21 |
+
if st.button("Generate Output"):
|
22 |
+
if user_input:
|
23 |
+
# Tokenize the input
|
24 |
+
inputs = tokenizer(user_input, return_tensors="pt")
|
25 |
+
|
26 |
+
# Forward pass through the model
|
27 |
+
with torch.no_grad():
|
28 |
+
outputs = model(**inputs)
|
29 |
+
|
30 |
+
# Get the output embeddings or logits (depending on the model structure)
|
31 |
+
# For example, let's say we want to display embeddings
|
32 |
+
st.write("Model Output Embeddings:", outputs.last_hidden_state)
|
33 |
+
|
34 |
+
else:
|
35 |
+
st.write("Please enter some input.")
|