Logo de Document Classification

Document Classification

Comunidade
Ruinius
Document Classification

Classify financial PDFs by extracting company identity, document type, and date metadata. Validates ticker via Yahoo Finance with multi-step fallback. Uses a Python orchestration script for validation, file modification, and writing markdown.

Visão geral

Publicado porRuinius
Repositóriofinancial-analyst-skills
Nome da habilidadeDocument Classification
Estrelas
5
Forks
1
Arquivos incluídos
6
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Arquivos incluídos: 6

    Scripts, templates e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente para leitura e nunca são executados.

  • Código aberto

    Publicada por Ruinius no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Document Classification no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/Ruinius/financial-analyst-skills/tree/main/skills/document_classification
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Ruinius/financial-analyst-skills.git /tmp/financial-analyst-skills
mkdir -p .claude/skills
cp -r /tmp/financial-analyst-skills/skills/document_classification .claude/skills/ruinius-document-classification
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Document Classification em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Document Classification automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Document Classification não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Document Classification Skill

This skill takes a PDF from input_data/, classifies it, abstracts metadata, and uses an orchestration script to validate the company ticker and produce a standardized markdown file in processing_data/.

Prerequisites

  • Python 3.10+
  • PDFs placed in input_data/ directory at the project root
  • If a static file server is not running on localhost:8181 then ask the user to run .\tools\start_file_server.bat

DO NOT EVER start servers without human user.

Inputs

  • One or more PDF files in input_data/

Outputs

  • Renamed PDF in processing_data/: TICKER_DOCTYPE_YYYYMMDD_temp.pdf
  • Markdown file in processing_data/: TICKER_DOCTYPE_YYYYMMDD_temp.md

Step-by-Step Instructions

Batch Mode: Repeat Steps 1–6 for EVERY .pdf file in input_data/. Track which files have been processed and continue until all are done. Report a summary at the end.

Step 1: Pick the Next PDF to Process

  1. List all .pdf files in input_data/
  2. If no PDFs exist (or all have already been processed), stop and inform the user: "No PDFs found in input_data/" or "All PDFs processed."
  3. Pick the next unprocessed PDF in input_data/. Keep track of its filename.
  4. Continue to Step 2 for this PDF.

Step 2: Read the PDF

  1. Ensure a background process running the file server is active (.\tools\start_file_server.bat).
  2. Open the PDF in the browser using the browser_subagent tool:
    • Navigate to the PDF via the local server, e.g., http://localhost:8181/input_data/{filename}
    • The browser renders PDFs natively with full visual fidelity
  3. Read the first 1–3 pages to extract classification metadata (company name, ticker, document type, dates)
  4. For large documents (10-K, 10-Q, analyst reports), you do NOT need to read every page — focus on the cover page and table of contents
  5. Do NOT use PyPDF2 or other text extraction libraries — the browser approach preserves table layouts and handles scanned/image-based documents
  6. If the PDF cannot be opened in the browser, stop and inform the user

Step 3: Classify the Document

From the PDF content read in Step 2, extract the following fields. Refer to skills/document_classification/resources/document_types.json for validation and exact naming of Document Types.

Fields to extract:

FieldFormatDescription
document_typestringMUST strictly be one of the keys in document_types.json
company_namestring or nullCompany name as found in the document
tickerstring or nullStock ticker symbol (uppercase, 1-5 chars)
confidencestringOne of: high, medium, low

Anti-hallucination rules:

  • ONLY extract information EXPLICITLY shown in the document text
  • DO NOT invent, infer, or assume company names, tickers, or dates
  • If information is not visible, use null
  • DO NOT use external knowledge to fill in missing information at this step

Step 4: Extract Dates

Extract each date field carefully, paying close attention to the document context.

Fiscal Year Awareness: Before assigning time_period, check skills/document_classification/resources/fiscal_year_map.json to see if this company has a non-standard fiscal year. Many retail and tech companies (e.g., LULU, WMT, COST, NKE, BABA) have fiscal years ending in months other than December. This shifts which calendar months map to which fiscal quarters.

  • If the ticker IS in the map, use the fiscal_year_ends entry to determine the correct fiscal quarter from the period_end_date.
  • If the ticker is NOT in the map, assume a standard calendar fiscal year (ending December 31).
4a: Extract document_date
  • The date the document was published or released
  • Format: YYYY-MM-DD
4b: Extract time_period
  • The fiscal reporting period
  • Format: Q1 YYYY, Q2 YYYY, Q3 YYYY, Q4 YYYY, or FY YYYY
  • Important: Use the company's fiscal calendar, not the calendar year. For example, LULU's fiscal year ends in January, so a period ending Jan 28, 2024 is Q4 FY2023, not Q1 2024.
4c: Extract period_end_date
  • The date the financial period ended (quarter end or fiscal year end)
  • Format: YYYY-MM-DD

Step 5: Execute Orchestration Script

Run the python orchestration script to validate and finalize the classification. This script will automatically validate the ticker against Yahoo Finance, rename strings according to document type abbreviations, move the file, and create the final markdown file.

Execute the following terminal command with the correctly formatted strings from Steps 3 and 4:

bash
uv run python skills\document_classification\scripts\process_classification.py --filename "FILENAME.pdf" --company_name "Extracted Company Name" --ticker "TICKER" --document_type "document_type" --document_date "YYYY-MM-DD" --time_period "time_period" --period_end_date "YYYY-MM-DD" --confidence "high"

If it succeeds, output the success to the user. If there are more PDFs remaining in input_data/, return to Step 1 for the next file. Otherwise, print a final summary of all processed documents and finish the run.

💡 First-File Scenario: If the document is the first one being processed for a ticker (no output_data/TICKER exists), Phase 5 (Qualitative Assessment) will require you to manually initialize the ticker directory and TICKER_metadata.md file.

Step 6: Reflection — Use LLM Knowledge (Fallback)

If the script in Step 5 throws an error (e.g. invalid ticker):

  1. Ask the LLM: "Given this company name and document context, what is the correct stock ticker?"
  2. The LLM IS allowed to use its knowledge here (unlike Step 3)
  3. If a new ticker is found, re-run Step 5 with the new ticker.
  4. If it still fails, ask the human user for the correct ticker.

Error Handling

  • If PDF cannot be opened in the browser → Inform user, skip this PDF
  • If classification fails → Retry once, then inform user
  • If ticker validation completely fails → Ask human user for the correct ticker
  • If date extraction fails → Set failed fields to null, proceed with available data

Changelog

  • 2026-05-06: Updated example command to use uv run per project standards. Added note about first-file initialization for qualitative documents.

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Document Classification faz?

Classify financial PDFs by extracting company identity, document type, and date metadata. Validates ticker via Yahoo Finance with multi-step fallback. Uses a Python orchestration script for validation, file modification, and writing markdown.

Por que usar Document Classification no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Document Classification é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Document Classification no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/Ruinius/financial-analyst-skills/tree/main/skills/document_classification. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Document Classification?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Document Classification?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Document Classification com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Document Classification é gratuita?

Sim. A habilidade é publicada no GitHub por Ruinius sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇