elia-waefler commited on
Commit
98968f6
·
1 Parent(s): fcac63a

init files, idea

Browse files
Files changed (2) hide show
  1. app.py +28 -1
  2. requirements.txt +4 -1
app.py CHANGED
@@ -1,3 +1,30 @@
1
  """the idea is to embed all KBOB categories as vectores.
2
  then when a new document in added, we do a sim search with the doc vector in the KBOB vectores
3
- to map/classify. can be done in multiple steps. """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  """the idea is to embed all KBOB categories as vectores.
2
  then when a new document in added, we do a sim search with the doc vector in the KBOB vectores
3
+ to map/classify. can be done in multiple steps. """
4
+
5
+
6
+ import streamlit as st
7
+ from transformers import AutoModelForCausalLM, AutoTokenizer
8
+
9
+ # Load the model and tokenizer
10
+ model_name = "https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1"
11
+ model_name = "mistralai/Mixtral-8x7B-Instruct-v0.1" # gated
12
+ model_name = "mistral-community/Mistral-7B-v0.2"
13
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
14
+ model = AutoModelForCausalLM.from_pretrained(model_name)
15
+
16
+
17
+ # Function to generate text based on a prompt
18
+ def generate_text(llm_prompt):
19
+ inputs = tokenizer(llm_prompt, return_tensors="pt")
20
+ outputs = model.generate(inputs["input_ids"], max_length=100)
21
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
22
+
23
+
24
+ # Set up the Streamlit interface
25
+ st.title("Mistral 7B Text Generation App")
26
+ prompt = st.text_area("Enter your prompt:", "Once upon a time")
27
+ if st.button("Generate"):
28
+ with st.spinner('Generating...'):
29
+ generated_text = generate_text(prompt)
30
+ st.text_area("Generated Text:", generated_text, height=300)
requirements.txt CHANGED
@@ -7,4 +7,7 @@ langchain~=0.1.16
7
  tiktoken~=0.6.0
8
  numpy~=1.26.4
9
  requests~=2.31.0
10
- faiss-cpu
 
 
 
 
7
  tiktoken~=0.6.0
8
  numpy~=1.26.4
9
  requests~=2.31.0
10
+ faiss-cpu
11
+ transformers~=4.40.2
12
+ pandas~=2.2.2
13
+ pillow~=10.3.0