Spaces:
Runtime error
Runtime error
LegendaryToe
commited on
Commit
•
c07c602
1
Parent(s):
5e6328b
cp
Browse files
app.py
CHANGED
@@ -41,21 +41,23 @@
|
|
41 |
# for entity in entities:
|
42 |
# st.write(f"Entity: {entity['word']}, Entity Type: {entity['entity_group']}")
|
43 |
|
44 |
-
|
45 |
import streamlit as st
|
46 |
from transformers import pipeline
|
47 |
|
48 |
-
# Load
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
st.title('CodeBERT Feature Extractor')
|
53 |
|
54 |
-
# User input for text
|
55 |
-
user_input = st.text_area("Enter code or text to extract features:", "SELECT * FROM users;")
|
56 |
|
57 |
-
# Extract features
|
58 |
-
if st.button('Extract Features'):
|
59 |
-
features = codebert(user_input)
|
60 |
-
# Display extracted features (example: show size of feature vector for demonstration)
|
61 |
-
st.write('Number of features extracted:', len(features[0][0]))
|
|
|
41 |
# for entity in entities:
|
42 |
# st.write(f"Entity: {entity['word']}, Entity Type: {entity['entity_group']}")
|
43 |
|
|
|
44 |
import streamlit as st
|
45 |
from transformers import pipeline
|
46 |
|
47 |
+
# Load a smaller LLaMA model with permission to run custom code
|
48 |
+
text_generator = pipeline("text-generation", model="microsoft/Phi-3-mini-128k-instruct", trust_remote_code=True)
|
49 |
+
|
50 |
+
st.title('General Query Answerer')
|
51 |
+
|
52 |
+
# User input for a general question
|
53 |
+
user_query = st.text_area("Enter your question:", "Name all 50 US states.")
|
54 |
+
|
55 |
+
# Generate answer
|
56 |
+
if st.button('Answer Question'):
|
57 |
+
answer = text_generator(user_query, max_length=150)[0]['generated_text']
|
58 |
+
# Display the answer
|
59 |
+
st.write('Answer:', answer)
|
60 |
+
|
61 |
|
|
|
62 |
|
|
|
|
|
63 |
|
|
|
|
|
|
|
|
|
|