Nat TaylorBlog, AI, Product Management & Tinkering

Test Drive: Outlines

Published on .

Today I’m test driving Outlines which offers “Structured text generation and robust prompting for language models.” With over 8,000 stars on Github, outlines is a popular, battle-tested solution that I’ve been meaning to try for quite some time. I’ll do a simple company classification task. The process is:

  1. Install outlines
  2. Implement

Outlines shines at this task and I need to dive deeper.

import outlines

model = outlines.models.openai("gpt-4o-mini")

@outlines.prompt
def company_classifier(request):
    """You are an experienced business analyst.

    Given a company description, determine if it is small cap, mid cap or large cap.

    Request: {{ request }}
    Label: """

generator = outlines.generate.choice(model, ["SMALL", "MID", "LARGE"])

requests = [
    "Cummins Inc. designs, manufactures, distributes and services diesel and natural gas engines and engine-related component products. The Company's segments include Engine, Distribution, Components and Power Systems. The Engine segment manufactures and markets a range of diesel and natural gas powered engines under the Cummins brand name, as well as certain customer brand names, for the heavy and medium-duty truck, bus, recreational vehicle (RV), light-duty automotive and agricultural markets. The Distribution segment consists of the product lines, which service and/or distribute a range of products and services, including parts, engines, power generation and service. The Components segment supplies products, including aftertreatment systems, turbochargers, filtration products and fuel systems for commercial diesel applications. The Power Systems segment consists of businesses, including Power generation, Industrial and Generator technologies.",
    "PTT Public Company Limited is a Thailand-based company engaged in the gas and petroleum businesses. The Company supplies, transports and distributes natural gas vehicle (NGV), petroleum products and lubricating oil via service stations throughout Thailand and also exports to overseas markets. Through its subsidiaries and affiliated companies, the Company is involved in exploration, production, refinery, marketing and distribution of petroleum, petrochemical products and aromatics. In addition, the Company operates international trade businesses, including import and export of crude oil, condensates, petroleum products, petrochemicals, and sourcing of international transport vessels and carriers."
]

prompts = [company_classifier(request) for request in requests]

print([generator(prompt) for prompt in prompts])Code language: Python (python)

Popular Posts

Post Navigation

«
»