--- tags: - text2text-generation - financial-nlp - time-extraction - t5 language: en license: apache-2.0 widget: - text: "extract time: What was Apple's revenue for Q3 2023?" example_title: "Quarterly Period" - text: "extract time: Show me Tesla's gross margin for fiscal year 2022" example_title: "Annual Period" - text: "extract time: Get Microsoft's earnings for the third quarter of 2021" example_title: "Quarter with Year" --- # T5 Time Period Extractor This model extracts time periods from financial queries. ## Usage ```python from transformers import pipeline pipe = pipeline("text2text-generation", model="ak837/t5-time-period-extractor") # Important: Always prefix with "extract time: " result = pipe("extract time: What was Apple's revenue for Q3 2023?") print(result[0]['generated_text']) # Output should be JSON like: {"period":"quarter","year":2023,"quarter":3} ``` ## Training This model was fine-tuned to extract time periods from financial queries in a structured JSON format. ## Output Format The model outputs JSON with: - `period`: "quarter" or "annual" - `year`: The year (e.g., 2023) - `quarter`: Quarter number (1-4) if applicable ## Known Issue The model sometimes outputs JSON without proper braces. You may need to add them: ```python output = result[0]['generated_text'] if not output.startswith('{'): output = '{' + output + '}' ```