Global Unemployment transformed into Global Employment Chain of Thoughts - Season 1 Episode 2

Global Unemployment transformed into Global Employment Chain of Thoughts - Season 1 Episode 2

Recently updated and published the notebook here Global Unemployment Dataset Season 1 Idea 1

Upcoming April 2025, My father's fourth year death anniversary !! I want to do some good dedicated work for my father's lost soul!! Hence thinking about next version "Kanniappan's GED (Global Employment Datasets) Foundation LLM datasets"

These Kanniappan GED FLLM dataset purposefully created for Global Employment Agenda, Insurance company's are having Unemployment insurance coverages !! During Recession / Layoff timelines especially people who got the educational loans !! It created a lot of painful incidents, Hence removing recessions, layoffs, great depression !! These basic Kanniappan GED FLLM datasets created to develop more alternate reality versions of decommissioning / dismissing those bad situations !! Keep improving more hiring possibilities !!

No profits, Keep helping the Crowd of people get their career life choices was the agenda on upcoming Kanniappan GED FLLM datasets

Newly created Global Unemployment dataset

included extra one more feature column recent timeline 2020 to 2024, with Chain of thought prompt engineering


Hence in this dataset Global Unemployment Dataset

Now we have two csv files

Recently included code logic for COT Chain of thought prompt engineering technique here below code created

import os
import pandas as pd
from kaggle_secrets import UserSecretsClient
from google import genai
from IPython.display import Markdown

# -------------------------------------------------------------------
# Part 1: Load the expanded dataset and filter for recent records
# -------------------------------------------------------------------
# Load the dataset that you previously saved as 'global_unemployment_dataset.csv'
df = pd.read_csv('global_unemployment_dataset.csv')

# Define a helper function to extract the starting year from the timeline.
def extract_start_year(timeline):
    try:
        # Assume timeline is in the format "YYYY" or "YYYY-YYYY"
        year = int(timeline[:4])
        return year
    except Exception:
        return None

# Create a new column for the starting year
df['start_year'] = df['recession_timeline'].apply(extract_start_year)

# Filter for records with a start_year between 2020 and 2024.
df_recent = df[df['start_year'].between(2020, 2024)].copy()

# -------------------------------------------------------------------
# Part 2: Define the LLM class and generate chain-of-thought responses
# -------------------------------------------------------------------
class AgenticLLMAI:
    def __init__(self, api_key):
        os.environ["GOOGLE_API_KEY"] = api_key
        self.client = genai.Client()

    def generate_markdown_response(self, model_id, contents):
        # Generate a response from the LLM using the given prompt contents.
        response = self.client.models.generate_content(
            model=model_id,
            contents=contents
        )
        return response.text  # Return plain text (or wrap in Markdown() if desired)

# Get the API key using Kaggle's secrets (adjust as needed in your environment)
user_secrets = UserSecretsClient()
api_key = user_secrets.get_secret("GOOGLE_API_KEY")

# Initialize the LLM model with your API key.
llm_model = AgenticLLMAI(api_key)
model_id = "gemini-2.0-flash-exp"

# Define a function that builds a CoT prompt for a given record.
def generate_cot_prompt(row):
    prompt = (
        f"Considering the period '{row['recession_timeline']}' which is categorized as '{row['category']}',\n"
        f"with the root causes described as '{row['root_cause_recession']}',\n"
        f"and resolution approaches stated as '{row['how_it_resolved']}',\n"
        f"along with the key insights: '{row['key_insights']}',\n\n"
        "please provide a detailed chain-of-thought explanation covering:\n"
        "1. How was this recession/layoff/great depression addressed and controlled?\n"
        "2. What were the key learnings and insights from this event on global unemployment?\n"
        "3. What are the best action plans or recommendations for future similar scenarios, especially "
        "focusing on developments and responses from 2020 to 2024?\n\n"
        "Please be as detailed as possible."
    )
    return prompt

# Iterate over each recent record and generate a CoT response.
resolved_responses = []
for index, row in df_recent.iterrows():
    prompt = generate_cot_prompt(row)
    print(f"Generating response for id {row['id']}...")  # Optional: for progress tracking
    response = llm_model.generate_markdown_response(model_id, prompt)
    resolved_responses.append(response)

# Add the LLM responses as a new column in the filtered dataframe.
df_recent['resolved_recent_cot'] = resolved_responses

# -------------------------------------------------------------------
# Part 3: Merge the new responses back into the full dataset and save
# -------------------------------------------------------------------
# Merge the new column (based on 'id') back into the original dataframe.
df = df.merge(df_recent[['id', 'resolved_recent_cot']], on='id', how='left')

# Optionally drop the helper column 'start_year' if no longer needed.
df.drop(columns=['start_year'], inplace=True)

# Save the updated dataset as a new CSV file.
df.to_csv('global_unemployment_LLM_COT.csv', index=False)
print("Saved new dataset with LLM responses as 'global_unemployment_LLM_COT.csv'")        

要查看或添加评论,请登录

Kumaran Kanniappan ( I / we / Human )的更多文章

社区洞察

其他会员也浏览了