Labeler (class)
Base class for labeling operations using an LLM. Parameters (constructor)llm_model(str): Name of the LLM model to use (e.g.,"openai::gpt-4o-mini").unknown_label(str, optional): Label for unclear classifications (default:"unclear").temperature(float, optional): Temperature for the LLM model (default:0).
_deserialize_label_responses(responses): Deserialize LLM responses into a DataFrame._run_labeling_prompts(prompts, system_prompt, max_workers=100): Run prompts concurrently and collect LLM responses.
get_prompts_for_labeler
Generate a list of user messages for each text to be labelled by the labeling system. Parameterstexts(List[str]): Texts to get the labels from.textsconfig(Optional[List[Dict]], optional): Optional fields for the prompts in addition to the text.
List[str]: List of prompts for the labeling system.
parse_labeling_response
Parse the response from the LLM model used for labeling. Parametersresponse(str): The response from the LLM model as a raw string.
dict: Parsed dictionary with keys:motivationlabel
NarrativeLabeler (class)
LLM-powered labeler for narrative labeling. Parameters (constructor)llm_model(str): Name of the LLM model to use.label_prompt(str, optional): Custom prompt for labeling (default: uses system prompt).unknown_label(str, optional): Label for unclear classifications (default:"unclear").temperature(float, optional): Temperature for the LLM model (default:0).
get_labels(theme_labels, texts, max_workers=50): Label a list of texts with the provided theme labels.post_process_dataframe(df): Post-process the labeled DataFrame for export.
get_prompts_for_labeler
Generate a list of user messages for each text to be labelled by the labeling system. Parameterstexts(List[str]): Texts to get the labels from.textsconfig(Optional[List[Dict]], optional): Optional fields for the prompts in addition to the text.
List[str]: List of prompts for the labeling system.
parse_labeling_response
Parse the response from the LLM model used for labeling. Parametersresponse(str): The response from the LLM model as a raw string.
dict: Parsed dictionary with keys:motivationlabel
ScreenerLabeler (class)
LLM-powered labeler for thematic screener labeling. Parameters (constructor)llm_model(str): Name of the LLM model to use.label_prompt(str, optional): Custom prompt for labeling (default: uses system prompt).unknown_label(str, optional): Label for unclear classifications (default:"unclear").temperature(float, optional): Temperature for the LLM model (default:0).
get_labels(main_theme, labels, texts, max_workers=50): Label a list of texts with the provided main theme and labels.post_process_dataframe(df): Post-process the labeled DataFrame for export, including company/entity columns and placeholder replacement.
get_prompts_for_labeler
Generate a list of user messages for each text to be labelled by the labeling system. Parameterstexts(List[str]): Texts to get the labels from.textsconfig(Optional[List[Dict]], optional): Optional fields for the prompts in addition to the text.
List[str]: List of prompts for the labeling system.
parse_labeling_response
Parse the response from the LLM model used for labeling. Parametersresponse(str): The response from the LLM model as a raw string.
dict: Parsed dictionary with keys:motivationlabel