Spaces:
Build error

Nassira commited on
Commit
8114b7a
·
verified ·
1 Parent(s): 00bc84d

Update cv_prompt.py

Browse files
Files changed (1) hide show
  1. cv_prompt.py +29 -54
cv_prompt.py CHANGED
@@ -1,54 +1,29 @@
1
- import json
2
-
3
- def load_json_file(filename):
4
- try:
5
- with open(filename, 'r', encoding='utf-8') as f:
6
- return json.load(f)
7
- except json.JSONDecodeError as e:
8
- print(f"Error decoding JSON in {filename}: {e}")
9
- return None
10
-
11
- cv_completeness_data = load_json_file('cv_completeness.json')
12
- cv_sections = load_json_file('cv_sections.json')
13
-
14
- def get_section_detection_prompt(text):
15
- if cv_sections is None:
16
- return None
17
- sections_list = ", ".join(cv_sections['sections'].keys())
18
- return f"""<s>[INST] Analyze this CV text and identify which of the following sections are present: {sections_list}.
19
- A section is present if its content is identifiable, even without an explicit title.
20
- Consider synonyms and alternative phrasings.
21
-
22
- CV text:
23
- {text}
24
-
25
- Respond with a JSON object with a key "present_sections" containing an array of the identified sections. [/INST]"""
26
-
27
- def get_element_verification_prompt(text, section, cv_completeness_data):
28
- if cv_completeness_data is None:
29
- return None
30
-
31
- prompt = f"""<s>[INST] Analyze the following CV text for the '{section}' section. Identify all subsections (if any) and verify the presence of specific elements in each subsection.
32
-
33
- CV text:
34
- {text}
35
-
36
- For the '{section}' section, determine if the following elements are present in each subsection. Consider variations and synonyms of these elements. Respond with a JSON object where the key is '{section}', and the value is an array of objects, each representing a subsection with the following structure:
37
-
38
- {{
39
- "subsection_number": 1,
40
- "elements": [
41
- {{"name": "element_name", "present": true/false, "content": "extracted content if present"}}
42
- ]
43
- }}
44
-
45
- Elements to verify for each subsection of {section}:
46
- """
47
-
48
- section_data = next((s for s in cv_completeness_data['sections'] if s['name'] == section), None)
49
- if section_data:
50
- for element in section_data['elements']:
51
- prompt += f"- {element['name']}\n"
52
-
53
- prompt += "\nProvide your response as a valid JSON object. Ensure to identify all subsections present in the CV text, even if there's only one. [/INST]"
54
- return prompt
 
1
+ {
2
+ "sections": [
3
+ {
4
+ "name": "Summary and objective",
5
+ "elements": [
6
+ {"name": "Brief overview of professional background", "score": 1.5},
7
+ {"name": "Career goals or objectives", "score": 1.5}
8
+ ]
9
+ },
10
+ {
11
+ "name": "Education",
12
+ "elements": [
13
+ {"name": "Degree(s) obtained", "score": 1},
14
+ {"name": "Institution name(s)", "score": 1},
15
+ {"name": "Graduation date(s)", "score": 1}
16
+ ]
17
+ },
18
+ {
19
+ "name": "Work Experience",
20
+ "elements": [
21
+ {"name": "Job title(s)", "score": 0.8},
22
+ {"name": "Company name(s)", "score": 0.8},
23
+ {"name": "Employment dates", "score": 0.8},
24
+ {"name": "Key responsibilities", "score": 0.8},
25
+ {"name": "Achievements or notable projects", "score": 0.8}
26
+ ]
27
+ }
28
+ ]
29
+ }