deepak1307 commited on
Commit
19e71bd
·
0 Parent(s):

Duplicate from deepak1307/personalized-resume-q-a

Browse files
Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +13 -0
  3. app.py +91 -0
  4. requirements.txt +11 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Testing
3
+ emoji: 🐨
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 3.28.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: deepak1307/personalized-resume-q-a
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ from io import StringIO
4
+ import os,re
5
+ from langchain.llms import OpenAI
6
+ import pandas as pd
7
+
8
+ from langchain.document_loaders import UnstructuredPDFLoader
9
+
10
+ from langchain.prompts import PromptTemplate
11
+ from langchain.chains import LLMChain
12
+
13
+ from langchain.embeddings.openai import OpenAIEmbeddings
14
+ from langchain.vectorstores import Chroma
15
+ from langchain.text_splitter import CharacterTextSplitter
16
+ from langchain.llms import OpenAI
17
+ from langchain.chains import RetrievalQA
18
+ from langchain.document_loaders import TextLoader
19
+ from langchain.prompts import PromptTemplate
20
+
21
+ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
22
+
23
+ def predict(file_obj):
24
+ loader = UnstructuredPDFLoader(file_obj.orig_name)
25
+ data = loader.load()
26
+ text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
27
+ texts = text_splitter.split_documents(data)
28
+
29
+ embeddings = OpenAIEmbeddings()
30
+ docsearch = Chroma.from_documents(texts, embeddings)
31
+ qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="map_reduce", retriever=docsearch.as_retriever())
32
+
33
+ prompt_template = os.getenv("prompt_msg")
34
+ PROMPT = PromptTemplate(
35
+ template=prompt_template, input_variables=["context", "question"]
36
+ )
37
+ chain_type_kwargs = {"prompt": PROMPT}
38
+ qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=docsearch.as_retriever(), chain_type_kwargs=chain_type_kwargs)
39
+ response = []
40
+ category = ["Technical", "Education Background", "Behaviour", "Project Specific"]
41
+ for value in category:
42
+
43
+ response.append({value:ai(qa, value)})
44
+
45
+ html_output = ""
46
+ for obj in response:
47
+ # Loop through the key-value pairs in the object
48
+ for key, value in obj.items():
49
+ value = re.sub(r'[\d\.]+', '', value)
50
+ value_list = value.strip().split('\n')
51
+ value_html = "<ol>"
52
+ for item in value_list:
53
+ value_html += "<li>{}</li>".format(item.strip())
54
+ value_html += "</ol>"
55
+ html_output += "<h2>{}</h2>".format(key)
56
+ html_output += value_html
57
+
58
+
59
+ return html_output
60
+
61
+ def ai(qa,category):
62
+ query = "please suggest "+ category +" interview questions"
63
+ data = list(filter(None, qa.run(query).split('\n')))
64
+ results = list(filter(lambda x: x != ' ', data))
65
+ results = "\n".join(results)
66
+
67
+ return results
68
+
69
+ title = "Resume-to-Interview (R2I): Personalized Interview Questions Based on Your Resume"
70
+
71
+ description = "Our app uses the latest technology to scan your resume, and generates personalized interview questions based on your qualifications and experience. With Resume-to-Interview, you can focus on answering questions that are tailored to your specific skills, rather than wasting time memorizing generic interview questions."
72
+
73
+ article = """As students prepare to enter the job market, it's important to make sure they are well-equipped to handle interviews. However, many students find themselves struggling to remember all the possible questions they might be asked. This is where Resume-to-Interview comes in. Our app makes it easy for students to prepare for interviews by generating personalized interview questions based on their resume.
74
+
75
+ Using cutting-edge technology, our app analyzes the key details in your resume and generates a list of questions that are tailored to your unique skills and qualifications. This means that you can spend your time preparing for the questions that are most likely to come up during your interview.
76
+
77
+ The questions are divided into four categories: Technical, Education Background, Behaviour, and Project Specific. This allows you to focus on the areas where you are strongest, and provides you with a clear roadmap for preparing for your interview.
78
+
79
+ We believe that our app can help students to feel more confident and prepared as they enter the job market. By using Resume-to-Interview, you can be sure that you are fully prepared for your interview, and that you have the knowledge and skills needed to succeed in your chosen career.
80
+
81
+ Overall, we think that Resume-to-Interview is a valuable tool for anyone who is looking to enter the job market. It's easy to use, highly effective, and provides students with the personalized guidance they need to succeed in their interviews."""
82
+
83
+
84
+ iface = gr.Interface(fn =predict,
85
+ inputs = [gr.File(type="file",label="upload resume pdf file only",file_types=[".pdf"])],
86
+ outputs = [
87
+ gr.HTML()
88
+ ,
89
+ ],allow_flagging="never", title=title, description=description, article=article)
90
+
91
+ iface.launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ langchain
2
+ openai
3
+ pdfminer
4
+ unstructured
5
+ pdfminer.six
6
+ tiktoken
7
+ pandas
8
+ chroma
9
+ chromadb
10
+ unstructured-inference
11
+ flask