Skip to content
Merged
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
16 changes: 8 additions & 8 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ All extraction goes through `SkillExtractorRefactored.extract_concepts`. This pa
|---|---|
| `data` | a pandas `DataFrame`, one row per document |
| `id_column` | column holding each document's identifier; copied to the output. Default `"Research ID"` |
| `text_columns` | columns holding the text to analyse; joined with spaces for job descriptions |
| `input_type` | what kind of text the rows contain — selects the prompt |
| `text_columns` | columns holding the text to analyse; joined with spaces |
| `input_type` | what kind of text the rows contain; every type currently uses the same prompt |

### Input types

| `input_type` | Use for | Text used |
|---|---|---|
| `"job_desc"` (or `"job_description"`) | job postings and role descriptions | every column in `text_columns` |
| `"syllabus"`, `"course_syllabus"`, `"course_syllabi"` | courses and programs | the `description` and `learning_outcomes` columns — list both in `text_columns` |
| `"syllabus"`, `"course_syllabus"`, `"course_syllabi"` | courses and programs | every column in `text_columns`, e.g. `["description", "learning_outcomes"]` |

!!! note "List both syllabus columns"
The syllabus prompt treats the course description and its learning outcomes separately, reading them
from the `description` and `learning_outcomes` columns. Only columns named in `text_columns` are read,
so pass `text_columns=["description", "learning_outcomes"]`. With only `description`, the learning
outcomes reach the model empty.
!!! note "One prompt for every input type"
Job postings and syllabi go through the same extraction prompt, so skills extracted from either can
be compared directly. The prompt is worded for job postings and tells the model to ignore branding,
benefits and legal boilerplate; course text passes through it unchanged. List every column you want
the model to read in `text_columns`.

## What to extract

Expand Down
2 changes: 0 additions & 2 deletions laiser/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@
}}
"""

## ISSUE: Prompt for course syllabi
SKILL_EXTRACTION_PROMPT_SYLLABUS = """ Work in progress"""
KSA_EXTRACTION_PROMPT = """[INST]user
**Objective:** Given a {input_desc}, complete the following tasks with structured outputs.

Expand Down
34 changes: 12 additions & 22 deletions laiser/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
KSA_EXTRACTION_PROMPT,
KT_FROM_SKILLS_PROMPT,
SCQF_LEVELS,
SKILL_EXTRACTION_PROMPT_SYLLABUS,
)
from laiser.data_access import DataAccessLayer, FAISSIndexManager, KnowledgeFAISSIndexManager, TaskFAISSIndexManager
from laiser.exceptions import InvalidInputError, LAiSERError
Expand Down Expand Up @@ -52,18 +51,14 @@ def normalize_input_type(input_type: str) -> str:

@staticmethod
def build_skill_extraction_prompt(input_text: str, input_type: str) -> str:
"""Build prompt for basic skill extraction"""
input_type = PromptBuilder.normalize_input_type(input_type)
if input_type == "job_desc":
extraction_prompt = COMBINED_EXTRACTION_PROMPT.format(description=input_text)
return extraction_prompt
elif input_type == "syllabus":
return SKILL_EXTRACTION_PROMPT_SYLLABUS.format(
description=input_text.get("description", ""),
learning_outcomes=input_text.get("learning_outcomes", ""),
)
else:
raise InvalidInputError(f"Unsupported input type: {input_type}")
"""Build the skill extraction prompt.

Every input type uses the same prompt, so that skills extracted from
job postings and from syllabi stay comparable. ``input_type`` is still
validated, so an unsupported type fails here.
"""
PromptBuilder.normalize_input_type(input_type)
return COMBINED_EXTRACTION_PROMPT.format(description=input_text)

@staticmethod
def build_ksa_extraction_prompt(
Expand Down Expand Up @@ -960,16 +955,11 @@ def _deduplicate(self, items: List[str], semantic_threshold: float = 0.92) -> Li
return [exact_deduped[i] for i in kept_indices]

def extract_raw_llm_skills(self, input_data, text_columns, input_type: str = "job_desc"):
normalized_input_type = self.prompt_builder.normalize_input_type(input_type)
if normalized_input_type == "syllabus":
prompt_input: Any = {
"description": str(input_data.get("description", "")).strip(),
"learning_outcomes": str(input_data.get("learning_outcomes", "")).strip(),
}
else:
prompt_input = " ".join(str(input_data.get(col, "")) for col in text_columns).strip()
# Every input type reads the same columns and uses the same prompt. Syllabi
# previously went to a placeholder prompt that contained no document text.
prompt_input = " ".join(str(input_data.get(col, "")) for col in text_columns).strip()
extraction_prompt = self.prompt_builder.build_skill_extraction_prompt(
input_text=prompt_input, input_type=normalized_input_type
input_text=prompt_input, input_type=input_type
)
response = self.router.generate(extraction_prompt)
skills = self.llm_parser._parse_skills_from_response(response)
Expand Down
11 changes: 0 additions & 11 deletions paper.bib
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
@article{Autor2013,
author = {Autor, David H. and Dorn, David},
title = {The Growth of Low-Skill Service Jobs and the Polarization of the US Labor Market},
journal = {American Economic Review},
year = {2013},
volume = {103},
number = {5},
pages = {1553--1597},
doi = {10.1257/aer.103.5.1553}
}

@article{Boselli2018,
author = {Boselli, Roberto and Cesarini, Mirko and Mercorio, Fabio and Mezzanzanica, Mario},
title = {Classifying online Job Advertisements through Machine Learning},
Expand Down
Loading
Loading