Skip to content

Instantly share code, notes, and snippets.

@rjurney
Created August 9, 2025 04:51
Show Gist options
  • Save rjurney/9c5a685f38d6607558828607a407b060 to your computer and use it in GitHub Desktop.
Save rjurney/9c5a685f38d6607558828607a407b060 to your computer and use it in GitHub Desktop.
LLM Entity Matching + Merging Proof-of-Concept with BAML + Gemini 2.5 Pro
client<llm> Gemini25Pro {
provider google-ai
retry_policy ThreeRetries
options {
model "gemini-2.5-pro"
api_key env.GEMINI_API_KEY
}
}
retry_policy ThreeRetries {
max_retries 3
}
class Ticker {
name string
@description("Name of the company")
symbol string
@description("Ticker symbol of the company if publicly traded")
exchange string?
@description("Exchange where the company is traded")
}
class Company {
name string
@description("Formal name of the company with company suffix")
ticker Ticker?
@description("Ticker symbol of the company if publicly traded")
description string?
@description("Description of the company")
website_url string?
@description("URL of the company's website")
headquarters_location string?
@description("Location of the company's headquarters")
revenue_usd int?
@description("Revenue of the company in USD")
employees int?
@description("Number of employees of the company")
founded_year int?
@description("Year the company was founded")
ceo string?
@description("Name of the company's CEO")
linkedin_url string?
@description("LinkedIn URL of the company")
}
function EntityResolution(company_one: Company, company_two: Company) -> Company {
// see clients.baml
client CustomGeminiFallback
// The prompt uses Jinja syntax. Change the models or this text and watch the prompt preview change!
prompt #"
Examine the following two companies and determine if they are the same entity. If they are, return the resolved company with all attributes filled out. If they are not, return an empty company object.
{# special macro to print the output instructions. #}
{{ ctx.output_format(hoist_classes=["Company", "Ticker"]) }}
{{ _.role("user") }}
Company One: {{ company_one }}
Company Two: {{ company_two }}
{{ _.role("assistant") }}
{{ ctx.output_instructions("Return a single company object with all attributes filled out if the two companies are the same entity. If they are not the same company, do not combine them.") }}
"#
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment