Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- README.md +2 -12
- app.py +22 -0
- requirements.txt +3 -0
README.md
CHANGED
@@ -1,12 +1,2 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
emoji: 😻
|
4 |
-
colorFrom: purple
|
5 |
-
colorTo: gray
|
6 |
-
sdk: streamlit
|
7 |
-
sdk_version: 1.36.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
# mathstral_assistant
|
2 |
+
# Mathstral-7B Assistant for Physics, Engineering, and Mathematics This Streamlit app provides an interface for the Mathstral-7B model, assisting with questions in physics, engineering, and mathematics. ## Setup and Running 1. Clone this repository:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
|
4 |
+
# Load the model and tokenizer
|
5 |
+
model_name = "mistralai/mathstral-7B-v0.1"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
+
|
9 |
+
st.title("Mathstral-7B Assistant for Physics, Engineering, and Mathematics")
|
10 |
+
|
11 |
+
st.write("Enter your question related to physics, engineering, or mathematics:")
|
12 |
+
prompt = st.text_area("Question:", "Example: Calculate the force on an object with mass 10 kg and acceleration 2 m/s².")
|
13 |
+
|
14 |
+
max_length = st.sidebar.slider("Max Response Length", min_value=10, max_value=200, value=100)
|
15 |
+
|
16 |
+
if st.button("Generate Response"):
|
17 |
+
with st.spinner("Generating response..."):
|
18 |
+
full_prompt = f"Assistant in physics, engineering, and mathematics: {prompt}"
|
19 |
+
inputs = tokenizer(full_prompt, return_tensors="pt")
|
20 |
+
outputs = model.generate(**inputs, max_length=max_length)
|
21 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
22 |
+
st.write("Response:", response)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
transformers
|
3 |
+
torch
|