Last active
January 26, 2025 13:27
-
-
Save janwirth/861e353e99a9be69a2491dc6394fedbf to your computer and use it in GitHub Desktop.
Knowledge Triple Extraction DSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { generateObject, generateText } from "ai"; | |
import { test } from "bun:test"; | |
import z from "zod"; | |
import { cerebrasLlama8 } from "../../../llm-models"; | |
const DSL = `Use the following format | |
Subject -> relationship -> Object `; | |
test.only("break llama", async () => { | |
const schema = z.array( | |
z.object({ | |
subject: z.string(), | |
relationship: z.string(), | |
object: z.string(), | |
}), | |
); | |
const result = await generateObject({ | |
model: cerebrasLlama8, | |
prompt: `Your task is to extract facts as knowledge triples from text. | |
Rules | |
- Limit Subject and Object to three words maximum. | |
- 'relationship' is always one word | |
- Extract as many facts as possible | |
Here is the text: | |
""" | |
${text} | |
""" | |
`, | |
schema: z.object({ facts: schema }), | |
temperature: 0, | |
}); | |
console.log( | |
result.object.facts | |
.map((x, idx) => `${idx} ${JSON.stringify(x)}`) | |
.join("\n"), | |
); | |
const result_ = await generateText({ | |
model: cerebrasLlama8, | |
prompt: `Your task is to extract facts as knowledge triples from text. | |
Rules | |
- Limit Subject and Object to three words maximum. | |
- 'relationship' is always one word | |
- Extract as many facts as possible | |
${DSL} | |
Here is the text: | |
""" | |
${text} | |
""" | |
`, | |
temperature: 0, | |
}); | |
console.log(result_.text); | |
}); | |
const text = `Conception | |
The idea of DOGE has been linked to Trump's campaign promises to cut federal spending and reduce the size of government and the size of the federal fiscal deficit.[8][9] | |
The concept of DOGE emerged in a discussion between Elon Musk and Donald Trump, where Musk floated the idea of a department for streamlining government efficiency. In August 2024, Trump said at a campaign event that, if he were elected, he would be open to giving Musk an advisory role.[10] In response, Musk wrote a post on X saying "I am willing to serve", along with an AI-created image of him standing in front of a lectern marked "Department of Government Efficiency".[11] The organization's acronym DOGE has been described as referencing dogecoin, a cryptocurrency that Musk promotes,[12] and the DOGE website's official launch prominently featured the dogecoin logo of a Shiba Inu dog.[13] Later, the suggestion was made by Trump of establishing such a department and for it to be headed by Musk.[14][15] | |
Musk has suggested that the organization could help to cut the U.S. federal budget by up to US$2 trillion through measures such as reducing waste, abolishing redundant agencies, and downsizing the federal workforce. Ramaswamy also stated that DOGE may eliminate entire federal agencies and reduce the number of federal employees by as much as 75%.[16][17] DOGE may attempt to do this through re-enacting Schedule F.[18] Musk has also proposed consolidating the number of federal agencies from more than 400 to fewer than 100.[19] | |
Musk has described deregulation as the only path to the SpaceX Mars colonization program, and promised he will "get the government off people's back and out of their pocket".[20] | |
The organization is similar to attempts before it, including president Theodore Roosevelt's Keep Commission, president Ronald Reagan's appointment of J. Peter Grace to lead the Grace Commission, and vice president Al Gore's National Partnership for Reinventing Government.[21]`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment