Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extraction/oppenheimer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Julius Robert Oppenheimer, who often went by Robert or “Oppie,” is better known to most as the father of the atomic bomb. Born to a non-observing Jewish family in New York, Oppenheimer would spend the first half of the 20th century making numerous breakthroughs in physics (including the earliest black hole theory) before working on the Manhattan Project, which resulted in the United States dropping nuclear bombs on Hiroshima and Nagasaki. The film covers not only World War II but Oppenheimer’s 1954 security hearing by the Atomic Energy Commission, motivated in part by McCarthyist investigations into his left-wing, pro-union political leanings and suspected communist ties. It also didn’t help that Oppenheimer’s frequent womanizing led him to associate with several women who were, at one time or another, members of the Communist Party of America, placing the famous physicist under even further Red Scare scrutiny. Oppenheimer’s wife at the time of his death in 1967, the German-born Katherine “Kitty” Oppenheimer first met the famous scientist in 1939 while she was still married to her third husband. Her first marriage had been annulled in just under a year, while her second common-law husband was killed in action during the Spanish Civil War in 1937 while fighting as part of the Mackenzie–Papineau Battalion, composed of Canadian and American volunteers supporting the Republican faction. Like several of Oppenheimer’s associates, Kitty was a member of the Communist Party of America, though, in both the film and in the transcript of Oppenheimer’s hearings, she claims to have left the party prior to meeting him. The chairman of the U.S. Atomic Energy Commission in the 1950s, Lewis Strauss had an adversarial relationship with Oppenheimer. This took the form of ideological and political disagreements — the left-leaning Oppenheimer opposed building the hydrogen bomb, which the Republican Strauss sought to move ahead with — but there was also personal animosity between them after Oppenheimer mocked Strauss in a public hearing about the risks posed by exporting radioisotopes. This eventually resulted in the Strauss-backed 1954 hearings to revoke Oppenheimer’s security clearance, which would eventually come up during Strauss’s 1959 confirmation hearing for the position of U.S. Secretary of Commerce. After overseeing the creation of the Pentagon, lieutenant general (then brigadier general) Leslie Groves was tasked with directing the Manhattan Project in 1942. He was responsible for appointing Oppenheimer as its scientific-research coordinator and even circumvented the government’s concerns about his communist associations in order to fast-track his security clearance. Together, they chose the Los Alamos, New Mexico, location for the project and the eventual Trinity test, the first-ever detonation of a nuclear bomb. In the years that followed, Groves maintained his admiration for Oppenheimer, calling him a good man Oppenheimer’s girlfriend and eventual mistress, Jean Tatlock began her tumultuous relationship with him in 1936, and as a member of the Communist Party, she’s widely believed to be responsible for introducing him to radical politics. Their relationship continued after Oppenheimer’s marriage to Kitty, though the clinically depressed Tatlock would eventually die by suicide at the age of 29. It’s also believed that Oppenheimer named the Trinity test in tribute to her since she had introduced him to the poems of John Donne, whose sonnet “Batter my heart, three-person’d God” was the likely inspiration for the name. Frank, Oppenheimer’s younger brother by eight years, would follow in his big bro’s footsteps, becoming not only a physicist but a member of the Manhattan Project. He also shared Oppenheimer’s leftist political beliefs and, along with his wife Jackie, joined the Communist Party, though he did so against Oppenheimer’s advice. Another key scientist in the Manhattan Project, Ernest Lawrence met Oppenheimer during their time at the University of California, Berkeley, where he built his Nobel Prize–winning cyclotron, a precursor to the modern particle accelerator. He was close friends with Oppenheimer and he even named his son Robert after him. However, their political disagreements over Oppenheimer’s unionizing efforts and his brother’s communist leanings led to a souring of their relationship. Though he declined to testify against his former friend at the 1954 hearings, his critical statements were still used. A U.S. Army Intelligence officer, Boris Pash was tasked with investigating Oppenheimer (among others) for potential Soviet leanings during the war on the suspicion of leaks from the Berkeley wing of the Manhattan Project. However, when asked to testify in 1954, he was much less doubtful of Oppenheimer’s loyalty than Lewis Strauss was, never believing him to be a spy or recommending that his clearance be revoked. Onscreen, Affleck plays him with an icy cold demeanor, making him seem all the more ruthless. The Hungarian-German-American scientist who first conceived of nuclear chain reactions, Leo Szilard became a staunch opponent of using nuclear weapons on civilians. He drafted what would come to be known as the Szilard petition, urging President Harry S. Truman to inform Japan of the Allies’ terms of surrender and to allow them to either accept or refuse those terms before considering the nuclear option. One of the most prominent scientists of the 20th century, Danish physicist Niels Bohr is the reason we illustrate atoms the way we do (with electrons orbiting a nucleus, like a miniature solar system). Bohr was only briefly involved with the Manhattan Project, though Oppenheimer credits him with significant contributions. In the film, he’s first introduced giving a lecture on quantum physics at Cambridge as an excited young Oppenheimer looks on. An experimental physicist at the University of Chicago during the Manhattan Project, David Hill was one of 70 scientists who signed the Szilard petition. He also testified at Strauss’s Senate confirmation hearing, accusing him of twisting Oppenheimer’s security hearings into a petty smear campaign A fellow Manhattan Project physicist, Hungarian-American Edward Teller had some professional animosity with Oppenheimer over what kind of weapons to prioritize at the Manhattan Project, favoring his idea for a fusion-type weapon, rather than the fission-type one which was eventually used. (Teller referred to the former as “the Super.”) After consulting Oppenheimer, Teller initially refused to sign Szilard’s petition against using the atomic bomb on civilians, though he came to regret his decision in later years. Teller would also go on to be known as the father of the hydrogen bomb, the successor to the atomic bomb, and he would eventually testify against Oppenheimer in 1954. While playing Teller, Safdie can be instantly identified as the sweatiest man in the room. The U.S. president from 1945 to 1953, Harry Truman oversaw the end of World War II and authorized the use of nuclear weapons against Japan. He and Oppenheimer maintained starkly different opinions on nuclear power going forward (Truman was in the pro camp) and their perspectives on Hiroshima and Nagasaki were similarly opposed. In the film, when Oppenheimer expresses his regrets to Truman at a face-to-face meeting, Truman calls him “a crybaby” — an incident based on (alleged) historical fact. A German-American theoretical physicist, Hans Bethe was personally invited to the Manhattan Project by Oppenheimer, and would eventually oversee its T (Theoretical) Division, which calculated the A-bomb’s explosive yield. Bethe had been friends with Edward Teller for several years, but they had numerous major disagreements while working under Oppenheimer over what kind of weapon to approach, leading to the de-prioritizing of Teller’s idea for a fission device, “the Super.” Another Nobel Prize–winning physicist on the Manhattan Project, the Polish-born, New York-raised Isidor Isaac Rabi met Oppenheimer while the duo studied in Germany in the 1920s. They remained lifelong friends, and Rabi would even testify at Oppenheimer’s hearings in his defense. Krumholtz’s character is the only one who broaches the subject of Oppenheimer’s Judaism with him — a background they share — and he’s always making sure the father of the atomic bomb is well-fed. An inventor and scientific administrator, Vannevar Bush was responsible for communicating Oppenheimer’s work on the Manhattan Project to then-president Roosevelt in 1942. He was also part of the committee that advised Roosevelt’s successor, Truman, on using the atomic bomb against Japan posthaste. The executive director of the U.S. Congress Joint Committee on Atomic Energy, William Borden was a huge proponent of nuclear weapons development in the early 1950s, at a time when Oppenheimer was less enthused by the idea. Upon entering the private sector, Borden’s letter to FBI director J. Edgar Hoover, accusing him of being an agent of the Soviet Union, was instrumental in investigating Oppenheimer’s loyalty. In the film, he can mostly be seen compiling his file on Oppenheimer, though he does feature in a brief but memorable flashback in the cockpit of a fighter plane. Physicist Robert Serber was one of Oppenheimer’s colleagues at Berkeley and was another one of his personal appointees to the Manhattan Project. Serber came up with the code names for each of the bomb projects in development based on their appearance: “Little Boy” (dropped on Hiroshima), “Fat Man” (dropped on Nagasaki), and the unused “Thin Man” design, an enormous plutonium gun. Recruited for the Manhattan Project before he’d earned his graduate degree, Richard Feynman became one of the most renowned physicists of the 20th century. He initially had an administrative role on the project, but took on additional responsibilities over time, including devising safety procedures for uranium storage and theoretical calculations for a proposed uranium-hydride bomb (though this would prove unfeasible). His work in quantum electrodynamics would eventually win him a Nobel Prize in 1965. In the film, he can be seen playing the bongos, much as he did in real life. The one person on this list who needs no introduction, Albert Einstein’s name is practically synonymous with genius, but the renowned physicist hadn’t actually considered the possibility of nuclear weapons until he was convinced otherwise in 1939. Shortly thereafter, he signed the Einstein-Szilard letter — along with the very same Szilard who eventually led the demonstration petition — urging then-president Franklin Roosevelt to start a U.S. nuclear program, lest Nazi Germany beat them to it A professor of French Literature at Berkeley, Haakon Chevalier was close friends with Oppenheimer and even took in his and Kitty’s infant son Peter for several months so they could spend time together on their ranch. He was believed to be a member of the Communist Party, making his and Oppenheimer’s relationship a key subject of the 1954 hearings, given what came to be known as “the Chevalier incident.” At a party in 1943, Chevalier approached Oppenheimer with information about Soviet attempts to gain intel on the Manhattan Project through a British scientist named George Eltenton (Guy Burnet). When reporting this conversation to his military superiors, Oppenheimer embellished various details to obscure both Chevalier’s identity as well as his own. The creator of the world’s first nuclear reactor, Enrico Fermi was another world-renowned physicist and a late addition to the Manhattan Project in 1944. Along with Oppenheimer and Lawrence, he advised the Interim Committee on potential Japanese targets. After World War II, he worked closely with Oppenheimer on advising the Atomic Energy Commission against the development of hydrogen bombs and spoke in Oppenheimer’s defense at his hearings. The namesake of Walter White’s gangster-scientist alter ego in Breaking Bad, German theoretical physicist Werner Heisenberg is often credited as the originator of quantum mechanics. He was a major contributor to Germany’s atomic program during World War II and was subsequently captured by an allied U.S.-Britain mission to retrieve nuclear intelligence and personnel from Germany before the Soviet Union. In the film, Oppenheimer travels to Göttingen to study theory under Heisenberg upon the suggestion of Niels Bohr. A German-born physicist who took refuge in Britain during World War II, Klaus Fuchs — known at Los Alamos as Karl — worked on uranium enrichment for the Manhattan Project while spying for the Soviet Union. The identity of the spy remains a mystery in Oppenheimer until Strauss shares the news with Oppenheimer at a party several years after World War II. An Austro-Hungarian mathematician and logistician, Kurt Gödel was a close friend of Albert Einstein, whose association with Jewish members of the Vienna Circle placed him under Nazi scrutiny. He was subsequently conscripted to fight for Germany in 1939 but escaped to Princeton instead. In the film, he and Einstein can be seen walking the Princeton grounds when Oppenheimer approaches the latter for advice; Gödel appears only briefly, but leaves an impression with his admiration for trees, which he calls “the perfect structure.”
1 change: 1 addition & 0 deletions extraction/oppenheimer_short.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'Julius Robert Oppenheimer, often known as Robert or "Oppie", is heralded as the father of the atomic bomb. Emerging from a non-practicing Jewish family in New York, he made several breakthroughs, such as the early black hole theory, before the monumental Manhattan Project. His wife, Katherine “Kitty” Oppenheimer, was a German-born woman with a complex past, including connections to the Communist Party. Oppenheimer\'s journey was beset by political adversaries, notably Lewis Strauss, chairman of the U.S. Atomic Energy Commission, and William Borden, an executive director with hawkish nuclear ambitions. These tensions culminated in the famous 1954 security hearing. Influential figures like lieutenant general Leslie Groves, who had also overseen the Pentagon\'s creation, stood by Oppenheimer\'s side, having earlier chosen him for the Manhattan Project and the Los Alamos location. Intimate relationships, like that with Jean Tatlock, a Communist and the possible muse behind the Trinity test\'s name, and colleagues like Frank, Oppenheimer\'s physicist brother, intertwined with his professional life. Scientists such as Ernest Lawrence, Edward Teller, David Hill, Richard Feynman, and Hans Bethe were some of Oppenheimer\'s contemporaries, each contributing to and contesting the atomic age\'s directions. Boris Pash\'s investigations, and the perspectives of figures like Leo Szilard, Niels Bohr, Harry Truman, and others, framed the broader sociopolitical context. Meanwhile, individuals like Robert Serber, Enrico Fermi, Albert Einstein, and Isidor Isaac Rabi, among many others, each played their parts in this narrative, from naming the atomic bombs to pivotal scientific contributions and advisory roles. All these figures, together with the backdrop of World War II, McCarthyism, and the dawn of the nuclear age, presented a complex mosaic of ambitions, loyalties, betrayals, and ideologies.
3 changes: 3 additions & 0 deletions extraction/requirments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
langchain
openai
streamlit
80 changes: 80 additions & 0 deletions extraction/streamlit_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import streamlit as st
from langsmith import Client
from langchain.chat_models import ChatOpenAI
from langchain.chains import create_extraction_chain

st.set_page_config(page_title='🦜🔗 AutoGraph: Triple extraction')
client = Client()
def send_feedback(run_id, score):
client.create_feedback(run_id, "user_score", score=score)

st.title('🦜🔗 AutoGraph: Triple extraction')
st.info("LLMs are good at extracting structured output from natural lanaguge. This playground will extract knowledge graph triplets from the user input text using [OpenAI functions](https://openai.com/blog/function-calling-and-other-api-updates) and [LangChain](https://github.com/langchain-ai/langchain). Knowledge graph triplets help to represent relationships between entities in a structured manner.")

# Input text
with open("oppenheimer_short.txt", "r") as file:
oppenheimer_text = file.read()

# LLM
llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo")

# Knowledge triplet schema
default_schema = {
"properties": {
"subject": {"type": "string"},
"predicate": {"type": "string"},
"object": {"type": "string"},
},
"required": ["subject", "predicate", "object"],
}

# Create a text_area, set the default value to oppenheimer_text
MAX_CHARS = 2000 # Maximum number of characters
user_input_text = st.text_area("Enter your text (<2000 characters):", value=oppenheimer_text, height=200)
if len(user_input_text) > MAX_CHARS:
st.warning(f"Text is too long. Only {MAX_CHARS} characters allowed!")
user_input_text = user_input_text[:MAX_CHARS]

# Output formatting of triples
def json_to_markdown_table(json_list):
if not json_list:
return "No data available."

# Extract headers
headers = json_list[0].keys()
markdown_table = " | ".join(headers) + "\n"
markdown_table += " | ".join(["---"] * len(headers)) + "\n"

# Extract rows
for item in json_list:
row = " | ".join([str(item[header]) for header in headers])
markdown_table += row + "\n"

return markdown_table

# Form input and query
markdown_output = None
with st.form('myform', clear_on_submit=True):

submitted = st.form_submit_button('Submit')
if submitted:

with st.spinner('Calculating...'):

llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo")
chain = create_extraction_chain(default_schema, llm)
extraction_output = chain(user_input_text,include_run_info=True)
markdown_output = json_to_markdown_table(extraction_output['text'])
run_id = extraction_output["__run"].run_id

# Feeback
if markdown_output is not None:
st.markdown(markdown_output)
col_blank, col_text, col1, col2 = st.columns([10, 2,1,1])
with col_text:
st.text("Feedback:")
with col1:
st.button("👍", on_click=send_feedback, args=(run_id, 1))
with col2:
st.button("👎", on_click=send_feedback, args=(run_id, 0))