Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added quantum circuit probability predictor model #1191

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app (3).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from flask import Flask, render_template, request, jsonify
from chat import chatbot

app = Flask(__name__)


@app.route("/")
def hello():
return render_template('chat.html')

@app.route("/ask", methods=['POST'])
def ask():

message = str(request.form['messageText'])

bot_response = chatbot(message)

return jsonify({'status':'OK','answer':bot_response})


if __name__ == "__main__":
app.run()
26 changes: 26 additions & 0 deletions chat (1).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from peft import AutoPeftModelForCausalLM
from transformers import GenerationConfig
from transformers import AutoTokenizer
import torch
tokenizer = AutoTokenizer.from_pretrained("Vasanth/mistral-finetuned-alpaca")

model = AutoPeftModelForCausalLM.from_pretrained(
"Vasanth/mistral-finetuned-alpaca",
low_cpu_mem_usage=True,
return_dict=True,
torch_dtype=torch.float16,
device_map="cuda")

generation_config = GenerationConfig(
do_sample=True,
top_k=1,
temperature=0.1,
max_new_tokens=100,
pad_token_id=tokenizer.eos_token_id
)

def chatbot(message):
input_str = "###Human: " + message + " ###Assistant: "
inputs = tokenizer(input_str, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, generation_config=generation_config)
return tokenizer.decode(outputs[0], skip_special_tokens=True).replace(input_str, '')
2 changes: 2 additions & 0 deletions config (1).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
##OPEN API STUFF
OPENAI_API_KEY = "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"
Loading