5-Embeddings (with online models)

AI integration
Documentation about the research done on embeddings. Testing clustering, retrieval, and pricing of text-embedding-ada-002, text-embedding-3-large, mini_lm_l12_v2, bge_multilingual_gemma2
Published

March 10, 2025

Set API keys
pdf_files = glob(os.path.join("data", "*.pdf"))
client = qdrant_client.QdrantClient("qdrant_host:qdrant_port")
openai_api_key = "openai_api_key"
infomaniak_api_key = "infomaniak_api_key"
infomaniak_product_id = "infomaniak_product_id"
Define functions
import hashlib
import time
import uuid
import qdrant_client
from qdrant_client.http.models import Distance, VectorParams
import numpy as np
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
import pdfplumber
from openai import OpenAI
import requests
import json
from glob import glob
import os
import tiktoken
from transformers import AutoTokenizer

# Extract text from a PDF
def extract_text_from_pdf(pdf_path):
    text = ""
    with pdfplumber.open(pdf_path) as pdf:
        for page in pdf.pages:
            text += page.extract_text()
    return text

# Chunk text into manageable sizes
def chunk_text(text, chunk_size=250):
    words = text.split()
    return [' '.join(words[i:i+chunk_size]) for i in range(0, len(words), chunk_size)]

# Generate embeddings using OpenAI API
def generate_embeddings(chunks, model_name, api_key):
    # Initialize the OpenAI client
    client = OpenAI(api_key=api_key)

    embeddings = []
    for chunk in chunks:
        try:
            response = client.embeddings.create(
                input=chunk,
                model=model_name
            )
            embeddings.append(response.data[0].embedding)
        except Exception as e:
            print(f"Error generating embedding: {e}")
            embeddings.append(None)
    return embeddings

# Generate embeddings using Infomaniak API
def generate_embeddings_v2(chunks, product_id, model_name, api_token, chunk_count=0,rate=None):
    url = f"https://api.infomaniak.com/1/ai/{product_id}/openai/v1/embeddings"
    headers = {"Authorization": f"Bearer {api_token}", "Content-Type": "application/json"}
    embeddings = []
    for chunk in chunks:
        if rate is not None and chunk_count == rate:
            print("waiting one minute")
            time.sleep(60)  # Wait for one minute
            chunk_count = 0  # Reset the counter after waiting
        try:
            data = json.dumps({"input": [chunk], "model": model_name})
            response = requests.post(url, headers=headers, data=data)
            if response.status_code == 200:
                res_json = response.json()
                embeddings.append(res_json["data"][0]["embedding"])
            else:
                print(f"Error: {response.status_code} - {response.text}")
                embeddings.append(None)
        except Exception as e:
            print(f"Error generating embedding: {e}")
            embeddings.append(None)
        chunk_count += 1
    return chunk_count, embeddings

# Store embeddings in Qdrant
def recreate_collection(collection_prefix, model_name, vector_size):
    collection_name = f"{collection_prefix}-{model_name}"

    client.recreate_collection(
        collection_name=collection_name,
        vectors_config=VectorParams(size=vector_size, distance=Distance.COSINE)
    )

def store_embeddings_in_qdrant_v2(collection_prefix, model_name, embeddings, chunks):
    collection_name = f"{collection_prefix}-{model_name}"
    
    points = [
        {"id": str(uuid.UUID(hashlib.sha256(chunks[idx].encode('utf-8')).hexdigest()[:32])),
          "vector": vector, "payload": {"text": chunks[idx]}}
        for idx, vector in enumerate(embeddings) if vector is not None
    ]
    client.upsert(collection_name=collection_name, points=points)
    print(f"Embeddings stored in collection: {collection_name}")



def visualize_embeddings(client, collection_name):
    print(collection_name)
    all_points = []
    limit = 544  # Adjust based on expected collection size
    offset = 0

    while True:
        response = client.scroll(
            collection_name=collection_name,
            with_vectors=True,
            limit=limit,
            offset=offset
        )
        points, _ = response
        if not points:
            break

        print(len(all_points))
        all_points.extend(points)
        offset += len(points)  # Increment offset for the next batch
        break

    if not all_points:
        print(f"No points found in collection: {collection_name}")
        return

    # Extract vectors from the fetched points
    vectors = np.array([point.vector for point in all_points if point.vector is not None])
    if vectors.size == 0:
        print("No valid vectors to visualize.")
        return

    # Reduce dimensions for visualization
    reduced_vectors = PCA(n_components=2).fit_transform(vectors)
    plt.scatter(reduced_vectors[:, 0], reduced_vectors[:, 1], alpha=0.5)
    plt.title(f"Visualization of Embeddings ({collection_name})")
    plt.show()


def recreate_collections():
    recreate_collection("test", "text-embedding-ada-002", 1536)
    recreate_collection("test", "text-embedding-3-large", 3072)
    recreate_collection("test", "mini_lm_l12_v2", 384)
    recreate_collection("test", "bge_multilingual_gemma2", 3584)

def extract_text_in_chunks(pdf_path):
    raw_text = extract_text_from_pdf(pdf_path)
    chunks = chunk_text(raw_text)
    return chunks

def get_nb_tokens(chunks, model_name):
    tokenizer = tiktoken.get_encoding(model_name)
    nb_token=0
    for chunk in chunks:
        num_tokens = len(tokenizer.encode(chunk))
        nb_token+=num_tokens
    return f"Number of tokens: {nb_token}"
    
def get_nb_tokens_v2(chunks, model_name):
    tokenizer = AutoTokenizer.from_pretrained(model_name)
    nb_token=0
    for chunk in chunks:
        tokens = tokenizer.tokenize(chunk)
        token_count = len(tokens)
        nb_token+=token_count
    return f"Number of tokens: {nb_token}"

def retrieve_text_documents(qdrant_client,points,collection_name):
    retrieved_documents = []
    for result in points:
        document = qdrant_client.retrieve(
            collection_name=collection_name,
            ids=[result.id]  # Fetch document(s) by ID
        )
        retrieved_documents.append({
            'id': result.id,
            'score': result.score,
            'content': document[0].payload # Adjust key as needed
        })

    return retrieved_documents

def retrieve_qa_documents(qdrant_client, collection_name: str, prompt,model_name, api_key):
    client = OpenAI(api_key=api_key)
    response = client.embeddings.create(
        input=prompt,
        model=model_name
    )
    embeddings=response.data[0].embedding

    # Perform a vector search in the Qdrant collection
    search_results = qdrant_client.search(
        collection_name=collection_name,
        query_vector=embeddings,  # Wrap the vector in NamedVector
        limit=3  # Number of top results to retrieve
    )

    # Extract the results in a human-readable format
    retrieved_documents = retrieve_text_documents(qdrant_client,search_results,collection_name)

    return retrieved_documents

def retrieve_qa_documents_v2(qdrant_client, collection_name: str, prompt,model_name, api_token,product_id):
    url = f"https://api.infomaniak.com/1/ai/{product_id}/openai/v1/embeddings"
    headers = {"Authorization": f"Bearer {api_token}", "Content-Type": "application/json"}
    data = '{"input": ["'+prompt+'"],"model": "'+model_name+'"}'

    response = requests.post(url, headers=headers, data=data)
    if response.status_code == 200:
        res_json = response.json()
        embeddings=res_json["data"][0]["embedding"]

        # Perform a vector search in the Qdrant collection
        search_results = qdrant_client.search(
            collection_name=collection_name,
            query_vector=embeddings,  # Wrap the vector in NamedVector
            limit=3  # Number of top results to retrieve
        )

        # Extract the results in a human-readable format
        retrieved_documents = retrieve_text_documents(qdrant_client,search_results,collection_name)

        return retrieved_documents
    return None

def call_llm(prompt, documents, model, openai_api_key):
    document_texts = "\n".join([doc['content']['text'] for doc in documents])

    constructed_prompt = f"CONTENT:\n{document_texts}\n\nUSER PROMPT:\n{prompt}"

    client = OpenAI(
        api_key=openai_api_key,  # This is the default and can be omitted
    )

    response = client.chat.completions.create(
        messages=[
            {
                "role": "user",
                "content": constructed_prompt,
            }
        ],
        model=model,
    )

    return response.choices[0].message.content

def call_llm_v2(prompt, documents, model, product_id, api_key):
    document_texts = "\n".join([doc['content']['text'] for doc in documents])
    constructed_prompt = f"CONTENT:\n{document_texts}\n\nUSER PROMPT:\n{prompt}\n\nbased on only the content given by the user, create an answer for the prompt"

    URL = f"https://api.infomaniak.com/1/ai/{product_id}/openai/chat/completions"
    headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}

    data = {
        "messages": [
            {
                "content": constructed_prompt,
                "role": "user"
            }
        ],
        "model": model
    }
    
    # Convert dictionary to JSON string
    json_data = json.dumps(data)


    req = requests.request("POST", url = URL , data = json_data, headers = headers)
    res = req.json()

    return res["choices"][0]["message"]["content"]

Clustering

Embeddings are vector representations of text, where semantically similar texts are mapped to nearby points in a multidimensional space. In the context of QA document search, embeddings are used to transform both queries and document chunks into vectors, enabling efficient and accurate retrieval of the most relevant information through similarity matching.

Plots with more defined clusters indicate that the embeddings effectively capture the underlying semantic relationships in the data. Well-separated clusters show that similar content is grouped closely together while dissimilar content is pushed apart. This is crucial for QA tasks, as it ensures that queries map to the most relevant document chunks. Clear clusters improve precision and recall by reducing noise and ambiguity in the search process, ultimately leading to faster and more accurate answers.

Here are scatter plots visualizing the embeddings generated by three different models. Each point represents a document chunk, and their positions are determined by reducing the high-dimensional embeddings to two dimensions using PCA. These plots reveal how each model organizes the semantic relationships within the data. Comparing the scatter plots helps us evaluate which model creates better-defined clusters, critical for tasks like QA document search where precise semantic grouping directly impacts retrieval performance.

Create store and visualize embeddings
chunk_count=0

recreate_collections()

for pdf_path in pdf_files:
    chunks=extract_text_in_chunks(pdf_path)

    ada_embeddings = generate_embeddings(chunks, "text-embedding-ada-002", openai_api_key)
    store_embeddings_in_qdrant_v2("test", "text-embedding-ada-002", ada_embeddings, chunks)

    large_embeddings = generate_embeddings(chunks, "text-embedding-3-large", openai_api_key)
    store_embeddings_in_qdrant_v2("test", "text-embedding-3-large", large_embeddings, chunks)

    chunk_count, miniLLM_embeddings = generate_embeddings_v2(chunks, infomaniak_product_id, "mini_lm_l12_v2", infomaniak_api_key,chunk_count,50)
    store_embeddings_in_qdrant_v2("test", "mini_lm_l12_v2", miniLLM_embeddings, chunks)

    chunk_count, gemma_embeddings = generate_embeddings_v2(chunks, infomaniak_product_id, "bge_multilingual_gemma2", infomaniak_api_key,chunk_count,50)
    store_embeddings_in_qdrant_v2("test", "bge_multilingual_gemma2", gemma_embeddings, chunks)

    print(pdf_path+" updloaded")

visualize_embeddings(client,"test-text-embedding-ada-002")
visualize_embeddings(client,"test-text-embedding-3-large")
visualize_embeddings(client,"test-mini_lm_l12_v2")
visualize_embeddings(client,"test-bge_multilingual_gemma2")

openai

open source through infomaniak

The test was made embedding the content of 11 Wikipedia pages (Apollo 11, artificial intelligence, climate change, computers, French revolution, industrial revolution, theory of relativity, Shakespeare, solar system, titanic and World War II) and is executed outside the quarto because it needs API keys - and a few cents are spent for every run

Pricing

without embedding the texts, we can use tools to calculate the number of tokens (this depends in multiple factors including the embedding model used)

Estimate tokens per document per embedding
pdf_files = glob(os.path.join("data", "*.pdf"))

for pdf_path in pdf_files:
    chunks=extract_text_in_chunks(pdf_path)

    print("text-embedding-ada-002 - "+pdf_path+" "+get_nb_tokens(chunks,"cl100k_base"))
    print("text-embedding-3-large - "+pdf_path+" "+get_nb_tokens(chunks,"cl100k_base"))
    print("mini_lm_l12_v2 - "+pdf_path+" "+get_nb_tokens_v2(chunks,'sentence-transformers/all-MiniLM-L12-v2'))
    print("bge_multilingual_gemma2 - "+pdf_path+" "+get_nb_tokens_v2(chunks,'BAAI/bge-multilingual-gemma2'))
Output
# OUTPUT:
# text-embedding-ada-002 - data/SolarSystem.pdf Number of tokens: 14230
# text-embedding-3-large - data/SolarSystem.pdf Number of tokens: 14230
# mini_lm_l12_v2 - data/SolarSystem.pdf Number of tokens: 14658
# bge_multilingual_gemma2 - data/SolarSystem.pdf Number of tokens: 15191

# text-embedding-ada-002 - data/Apollo11.pdf Number of tokens: 19467
# text-embedding-3-large - data/Apollo11.pdf Number of tokens: 19467
# mini_lm_l12_v2 - data/Apollo11.pdf Number of tokens: 19573
# bge_multilingual_gemma2 - data/Apollo11.pdf Number of tokens: 20946

# text-embedding-ada-002 - data/ArtificialIntelligence.pdf Number of tokens: 16991
# text-embedding-3-large - data/ArtificialIntelligence.pdf Number of tokens: 16991
# mini_lm_l12_v2 - data/ArtificialIntelligence.pdf Number of tokens: 17752
# bge_multilingual_gemma2 - data/ArtificialIntelligence.pdf Number of tokens: 17993

# text-embedding-ada-002 - data/ClimateChange.pdf Number of tokens: 14831
# text-embedding-3-large - data/ClimateChange.pdf Number of tokens: 14831
# mini_lm_l12_v2 - data/ClimateChange.pdf Number of tokens: 15242
# bge_multilingual_gemma2 - data/ClimateChange.pdf Number of tokens: 16204

# text-embedding-ada-002 - data/relativity.pdf Number of tokens: 3177
# text-embedding-3-large - data/relativity.pdf Number of tokens: 3177
# mini_lm_l12_v2 - data/relativity.pdf Number of tokens: 3231
# bge_multilingual_gemma2 - data/relativity.pdf Number of tokens: 3276

# text-embedding-ada-002 - data/Titanic.pdf Number of tokens: 22555
# text-embedding-3-large - data/Titanic.pdf Number of tokens: 22555
# mini_lm_l12_v2 - data/Titanic.pdf Number of tokens: 22566
# bge_multilingual_gemma2 - data/Titanic.pdf Number of tokens: 24000

# text-embedding-ada-002 - data/IndustrialRevolution.pdf Number of tokens: 30555
# text-embedding-3-large - data/IndustrialRevolution.pdf Number of tokens: 30555
# mini_lm_l12_v2 - data/IndustrialRevolution.pdf Number of tokens: 30087
# bge_multilingual_gemma2 - data/IndustrialRevolution.pdf Number of tokens: 32073

# text-embedding-ada-002 - data/WWII.pdf Number of tokens: 20271
# text-embedding-3-large - data/WWII.pdf Number of tokens: 20271
# mini_lm_l12_v2 - data/WWII.pdf Number of tokens: 20012
# bge_multilingual_gemma2 - data/WWII.pdf Number of tokens: 21696

# text-embedding-ada-002 - data/computers.pdf Number of tokens: 15595
# text-embedding-3-large - data/computers.pdf Number of tokens: 15595
# mini_lm_l12_v2 - data/computers.pdf Number of tokens: 15762
# bge_multilingual_gemma2 - data/computers.pdf Number of tokens: 16566

# text-embedding-ada-002 - data/Shakespeare.pdf Number of tokens: 11046
# text-embedding-3-large - data/Shakespeare.pdf Number of tokens: 11046
# mini_lm_l12_v2 - data/Shakespeare.pdf Number of tokens: 11253
# bge_multilingual_gemma2 - data/Shakespeare.pdf Number of tokens: 11754

# text-embedding-ada-002 - data/FrenchRevolution.pdf Number of tokens: 19092
# text-embedding-3-large - data/FrenchRevolution.pdf Number of tokens: 19092
# mini_lm_l12_v2 - data/FrenchRevolution.pdf Number of tokens: 18789
# bge_multilingual_gemma2 - data/FrenchRevolution.pdf Number of tokens: 19938
model tokens price ($/M) price (total)
text-embedding-ada-002 187810 0.1 0.018781
text-embedding-3-large 187810 0.13 0.0244153
mini_lm_l12_v2 188925 0 0.0
bge_multilingual_gemma2 199637 0.073 0.014573500999999999*

* CHF to USD conversion as of 20th December 2024

Retrieval

Retrieval is the process of accessing and extracting relevant information from a dataset or knowledge base in response to a query. In advanced systems like those utilizing vector databases and embedding models, retrieval involves mapping both queries and stored data into a shared semantic space where similarities are measured, often using metrics like cosine similarity. Effective retrieval systems are essential for applications such as question answering, recommendation engines, and information search. They are designed to handle challenges like ambiguity in queries, diverse formats of stored data, and the need for contextual understanding. A robust retrieval mechanism ensures precision, relevance, and scalability, enabling seamless interaction between users and vast repositories of information.

As the content is already embedded with the previous code, we will now test the following questions to retrieve data (and afterwards use the same questions to test LLM’s answers):

How did technological advancements from the Industrial Revolution influence space exploration efforts like Apollo 11?

This question includes two different topics of our database

Retrieve documents
prompt="How did technological advancements from the Industrial Revolution influence space exploration efforts like Apollo 11?"

print("text-embedding-ada-002")
print(retrieve_qa_documents(client,"test-text-embedding-ada-002",prompt,"text-embedding-ada-002",openai_api_key))
print("text-embedding-3-large")
print(retrieve_qa_documents(client,"test-text-embedding-3-large",prompt,"text-embedding-3-large",openai_api_key))
print("mini_lm_l12_v2")
print(retrieve_qa_documents_v2(client,"test-mini_lm_l12_v2",prompt,"mini_lm_l12_v2",infomaniak_api_key,infomaniak_product_id))
print("bge_multilingual_gemma2")
print(retrieve_qa_documents_v2(client,"test-bge_multilingual_gemma2",prompt,"bge_multilingual_gemma2",infomaniak_api_key,infomaniak_product_id))
Output
# OUTPUT:

# ada002=[
#    {
#       "id":"869c5a67-7a92-f3e8-45a4-6226e73044d6",
#       "score":0.855299,
#       "content":{
#          "text":"followed by the words \"TASK ACCOMPLISHED, July 1969\".[221] The success of Apollo 11 demonstrated the United States\\' technological superiority;[221] and with the success of Apollo 11, America had won the Space Race.[222][223] New phrases permeated into the English language. \"If they can send a man to the Moon, why can\\'t they ...?\" became a common saying following Apollo 11.[224] Armstrong\\'s words on the lunar surface also spun off various parodies.[222] https://en.wikipedia.org/wiki/Apollo_11 25/5119/12/2024, 11:21 Apollo 11 - Wikipedia While most people celebrated the accomplishment, disenfranchised Americans saw it as a symbol of the divide in America, evidenced by protesters led by Ralph Abernathy outside of Kennedy Space Center the day before Apollo 11 launched.[225] NASA Administrator Thomas Paine met with Abernathy at the occasion, both hoping that the space program can spur progress also in other regards, such as poverty in the US.[226] Paine was then asked, and agreed, to host protesters as spectators at the launch,[226] and Abernathy, awestruck by the spectacle,[107] prayed for the astronauts.[226] Racial and financial inequalities frustrated citizens who wondered why money spent on the Apollo program was not spent taking care of humans on Earth. A poem by Gil Scott-Heron called \"Whitey on the Moon\" (1970) illustrated the racial inequality in the A girl holding The Washington Post newspaper stating \"\\'The Eagle Has United States that was highlighted by the Space Landed\\' – Two Men Walk on the Race.[222][227][228] The poem starts with: Moon\" A rat done bit my sister Nell. (with Whitey on the"
#       }
#    },
#    {
#       "id":"82c5a492-66a7-48d8-16c3-b58d7dfe5ef9",
#       "score":0.85465795,
#       "content":{
#          "text":"achieved something great. Drastic cuts, warned Caspar Weinberger, the deputy director of the Office of Management and Budget, might send a signal that \"our best years are behind us\".[233] After the Apollo 11 mission, officials from the Soviet Union said landing humans on the Moon was dangerous and unnecessary. At the time the Soviet Union was attempting to retrieve lunar samples robotically. The Soviets publicly denied there was a race to the Moon, and indicated they were not making an attempt.[234] Mstislav Keldysh said in July 1969, \"We are concentrating wholly on the https://en.wikipedia.org/wiki/Apollo_11 26/5119/12/2024, 11:21 Apollo 11 - Wikipedia creation of large satellite systems.\" It was revealed in 1989 that the Soviets had tried to send people to the Moon, but were unable due to technological difficulties.[235] The public\\'s reaction in the Soviet Union was mixed. The Soviet government limited the release of information about the lunar landing, which affected the reaction. A portion of the populace did not give it any attention, and another portion was angered by it.[236] The Apollo 11 landing is referenced in the songs \"Armstrong, Aldrin and Collins\" by the Byrds on the 1969 album Ballad of Easy Rider, \"Coon on the Moon\" by Howlin\\' Wolf on the 1973 album The Back Door Wolf, and \"One Small Step\" by Ayreon on the 2000 album Universal Migrator Part 1: The Dream Sequencer. Spacecraft The command module Columbia went on a tour of the United States, visiting 49 state capitals, the District of Columbia, and Anchorage,"
#       }
#    },
#    {
#       "id":"4f1b9f11-49af-bdac-f8db-85cd13d2a285",
#       "score":0.85301137,
#       "content":{
#          "text":"group of British scientists interviewed as part of the anniversary events reflected on the significance of the Moon landing: It was carried out in a technically brilliant way with risks taken ... that would be inconceivable in the risk-averse world of today ... The Apollo programme is arguably the greatest technical achievement of mankind to date ... nothing since Apollo has come close [to] the excitement that was generated by those astronauts—Armstrong, Aldrin and the 10 others who followed them.[274] 50th anniversary On June 10, 2015, Congressman Bill Posey introduced resolution H.R. 2726 to the 114th session of the United States House of Representatives directing the United States Mint to design and sell commemorative coins in gold, silver and clad for the 50th anniversary of the Apollo 11 mission. On January 24, 2019, the Mint released the Apollo 11 Fiftieth Anniversary commemorative coins to the public on its website.[275][276] A documentary film, Apollo 11, with restored footage of the 1969 event, premiered in IMAX on March 1, 2019, and broadly in theaters on March 8.[277][278] The Smithsonian Institute\\'s National Air and Space Museum and NASA sponsored the \"Apollo 50 Festival\" on the National Mall in Washington DC. The three-day (July 18 to 20, 2019) outdoor festival featured hands-on exhibits and activities, live performances, and speakers such as Adam Savage and NASA scientists.[279] As part of the festival, a projection of the 363-foot (111 m) tall Saturn V rocket was displayed on the east face of the 555-foot (169 m) tall"
#       }
#    }
# ]
# tree_large=[
#    {
#       "id":"2edd30b6-d202-c9b0-0c07-b974be3938ff",
#       "score":0.5274797,
#       "content":{
#          "text":"1968, Apollo 7 evaluated the command module in Earth orbit,[44] and in December Apollo 8 tested it in lunar orbit.[45] In March 1969, Apollo 9 put the lunar module through its paces in Earth orbit,[46] and in May Apollo 10 conducted a \"dress rehearsal\" in lunar orbit. By July 1969, all was in readiness for Apollo 11 to take the final step onto the Moon.[47] https://en.wikipedia.org/wiki/Apollo_11 5/5119/12/2024, 11:21 Apollo 11 - Wikipedia The Soviet Union appeared to be winning the Space Race by beating the US to firsts, but its early lead was overtaken by the US Gemini program and Soviet failure to develop the N1 launcher, which would have been comparable to the Saturn V.[48] The Soviets tried to beat the US to return lunar material to the Earth by means of uncrewed probes. On July 13, three days before Apollo 11\\'s launch, the Soviet Union launched Luna 15, which reached lunar orbit before Apollo 11. During descent, a malfunction caused Luna 15 to crash in Mare Crisium about two hours before Armstrong and Aldrin took off from the Moon\\'s surface to begin their voyage home. The Nuffield Radio Astronomy Laboratories radio telescope in England recorded transmissions from Luna 15 during its descent, and these were released in July 2009 for the 40th anniversary of Apollo 11.[49] Personnel Prime crew Position Astronaut Neil A. Armstrong Commander Second and last spaceflight Michael Collins Command Module Pilot Second and last spaceflight Edwin \"Buzz\" E. Aldrin Jr. Lunar Module Pilot Second and"
#       }
#    },
#    {
#       "id":"79376e4b-1cc3-c814-2a83-f84994432338",
#       "score":0.51252025,
#       "content":{
#          "text":"on September 20, 1963.[33] The idea of a joint Moon mission was abandoned after Kennedy's death.[34] An early and crucial decision was choosing lunar orbit rendezvous over both direct ascent and Earth orbit rendezvous. A space President John F. Kennedy rendezvous is an orbital maneuver in which two spacecraft navigate speaking at Rice University through space and meet up. In July 1962 NASA head James Webb on September 12, 1962 announced that lunar orbit rendezvous would be used[35][36] and that the Apollo spacecraft would have three major parts: a command module (CM) with a cabin for the three astronauts, and the only part that returned to Earth; a service module (SM), which supported the command module with propulsion, electrical power, oxygen, and water; and a lunar module (LM) that had two stages—a descent stage for landing on the Moon, and an ascent stage to place the astronauts back into lunar orbit.[37] This design meant the spacecraft could be launched by a single Saturn V rocket that was then under development.[38] Technologies and techniques required for Apollo were developed by Project Gemini.[39] The Apollo project was enabled by NASA's adoption of new advances in semiconductor device, including metal–oxide–semiconductor field-effect transistors (MOSFETs) in the Interplanetary Monitoring Platform (IMP)[40][41] and silicon integrated circuit (IC) chips in the Apollo Guidance Computer (AGC).[42] Project Apollo was abruptly halted by the Apollo 1 fire on January 27, 1967, in which astronauts Gus Grissom, Ed White, and Roger B. Chaffee died, and the subsequent investigation.[43] In October"
#       }
#    },
#    {
#       "id":"82c5a492-66a7-48d8-16c3-b58d7dfe5ef9",
#       "score":0.50763696,
#       "content":{
#          "text":"achieved something great. Drastic cuts, warned Caspar Weinberger, the deputy director of the Office of Management and Budget, might send a signal that \"our best years are behind us\".[233] After the Apollo 11 mission, officials from the Soviet Union said landing humans on the Moon was dangerous and unnecessary. At the time the Soviet Union was attempting to retrieve lunar samples robotically. The Soviets publicly denied there was a race to the Moon, and indicated they were not making an attempt.[234] Mstislav Keldysh said in July 1969, \"We are concentrating wholly on the https://en.wikipedia.org/wiki/Apollo_11 26/5119/12/2024, 11:21 Apollo 11 - Wikipedia creation of large satellite systems.\" It was revealed in 1989 that the Soviets had tried to send people to the Moon, but were unable due to technological difficulties.[235] The public\\'s reaction in the Soviet Union was mixed. The Soviet government limited the release of information about the lunar landing, which affected the reaction. A portion of the populace did not give it any attention, and another portion was angered by it.[236] The Apollo 11 landing is referenced in the songs \"Armstrong, Aldrin and Collins\" by the Byrds on the 1969 album Ballad of Easy Rider, \"Coon on the Moon\" by Howlin\\' Wolf on the 1973 album The Back Door Wolf, and \"One Small Step\" by Ayreon on the 2000 album Universal Migrator Part 1: The Dream Sequencer. Spacecraft The command module Columbia went on a tour of the United States, visiting 49 state capitals, the District of Columbia, and Anchorage,"
#       }
#    }
# ]
# mini_lm_l12_v2=[
#    {
#       "id":"869c5a67-7a92-f3e8-45a4-6226e73044d6",
#       "score":0.53086144,
#       "content":{
#          "text":"followed by the words \"TASK ACCOMPLISHED, July 1969\".[221] The success of Apollo 11 demonstrated the United States\\' technological superiority;[221] and with the success of Apollo 11, America had won the Space Race.[222][223] New phrases permeated into the English language. \"If they can send a man to the Moon, why can\\'t they ...?\" became a common saying following Apollo 11.[224] Armstrong\\'s words on the lunar surface also spun off various parodies.[222] https://en.wikipedia.org/wiki/Apollo_11 25/5119/12/2024, 11:21 Apollo 11 - Wikipedia While most people celebrated the accomplishment, disenfranchised Americans saw it as a symbol of the divide in America, evidenced by protesters led by Ralph Abernathy outside of Kennedy Space Center the day before Apollo 11 launched.[225] NASA Administrator Thomas Paine met with Abernathy at the occasion, both hoping that the space program can spur progress also in other regards, such as poverty in the US.[226] Paine was then asked, and agreed, to host protesters as spectators at the launch,[226] and Abernathy, awestruck by the spectacle,[107] prayed for the astronauts.[226] Racial and financial inequalities frustrated citizens who wondered why money spent on the Apollo program was not spent taking care of humans on Earth. A poem by Gil Scott-Heron called \"Whitey on the Moon\" (1970) illustrated the racial inequality in the A girl holding The Washington Post newspaper stating \"\\'The Eagle Has United States that was highlighted by the Space Landed\\' – Two Men Walk on the Race.[222][227][228] The poem starts with: Moon\" A rat done bit my sister Nell. (with Whitey on the"
#       }
#    },
#    {
#       "id":"2edd30b6-d202-c9b0-0c07-b974be3938ff",
#       "score":0.5207336,
#       "content":{
#          "text":"1968, Apollo 7 evaluated the command module in Earth orbit,[44] and in December Apollo 8 tested it in lunar orbit.[45] In March 1969, Apollo 9 put the lunar module through its paces in Earth orbit,[46] and in May Apollo 10 conducted a \"dress rehearsal\" in lunar orbit. By July 1969, all was in readiness for Apollo 11 to take the final step onto the Moon.[47] https://en.wikipedia.org/wiki/Apollo_11 5/5119/12/2024, 11:21 Apollo 11 - Wikipedia The Soviet Union appeared to be winning the Space Race by beating the US to firsts, but its early lead was overtaken by the US Gemini program and Soviet failure to develop the N1 launcher, which would have been comparable to the Saturn V.[48] The Soviets tried to beat the US to return lunar material to the Earth by means of uncrewed probes. On July 13, three days before Apollo 11\\'s launch, the Soviet Union launched Luna 15, which reached lunar orbit before Apollo 11. During descent, a malfunction caused Luna 15 to crash in Mare Crisium about two hours before Armstrong and Aldrin took off from the Moon\\'s surface to begin their voyage home. The Nuffield Radio Astronomy Laboratories radio telescope in England recorded transmissions from Luna 15 during its descent, and these were released in July 2009 for the 40th anniversary of Apollo 11.[49] Personnel Prime crew Position Astronaut Neil A. Armstrong Commander Second and last spaceflight Michael Collins Command Module Pilot Second and last spaceflight Edwin \"Buzz\" E. Aldrin Jr. Lunar Module Pilot Second and"
#       }
#    },
#    {
#       "id":"3eed40a9-825e-1070-fd53-defba388f1f4",
#       "score":0.5120459,
#       "content":{
#          "text":"17th century.[225] A change in marrying patterns to getting married later made people able to accumulate more human capital during their youth, thereby encouraging economic development.[226] Until the 1980s, it was universally believed by academic historians that technological innovation was the heart of the Industrial Revolution and the key enabling technology was the invention and improvement of the steam engine.[227] Marketing professor Ronald Fullerton suggested that innovative marketing techniques, business practices, and competition also influenced changes in the manufacturing industry.[228] Lewis Mumford has proposed that the Industrial Revolution had its origins in the Early Middle Ages, much earlier than most estimates.[229] He explains that the model for standardised mass production was the printing press and that \"the archetypal model for the industrial era was the clock\". He also cites the monastic emphasis on order and time-keeping, as well as the fact that medieval cities had at their centre a church with bell ringing at regular intervals as being necessary precursors to a greater synchronisation necessary for later, more physical, manifestations such as the steam engine. The presence of a large domestic market should also be considered an important driver of the Industrial Revolution, particularly explaining why it occurred in Britain. In other nations, such as France, markets were split up by local regions, which often imposed tolls and tariffs on goods traded among them.[230] Internal tariffs were abolished by Henry VIII of England, they survived in Russia until 1753, 1789 in France and 1839 in Spain. Governments\\' grant of limited"
#       }
#    }
# ]
# bge_multilingual_gemma2=[
#    {
#       "id":"2edd30b6-d202-c9b0-0c07-b974be3938ff",
#       "score":0.5173392,
#       "content":{
#          "text":"1968, Apollo 7 evaluated the command module in Earth orbit,[44] and in December Apollo 8 tested it in lunar orbit.[45] In March 1969, Apollo 9 put the lunar module through its paces in Earth orbit,[46] and in May Apollo 10 conducted a \"dress rehearsal\" in lunar orbit. By July 1969, all was in readiness for Apollo 11 to take the final step onto the Moon.[47] https://en.wikipedia.org/wiki/Apollo_11 5/5119/12/2024, 11:21 Apollo 11 - Wikipedia The Soviet Union appeared to be winning the Space Race by beating the US to firsts, but its early lead was overtaken by the US Gemini program and Soviet failure to develop the N1 launcher, which would have been comparable to the Saturn V.[48] The Soviets tried to beat the US to return lunar material to the Earth by means of uncrewed probes. On July 13, three days before Apollo 11\\'s launch, the Soviet Union launched Luna 15, which reached lunar orbit before Apollo 11. During descent, a malfunction caused Luna 15 to crash in Mare Crisium about two hours before Armstrong and Aldrin took off from the Moon\\'s surface to begin their voyage home. The Nuffield Radio Astronomy Laboratories radio telescope in England recorded transmissions from Luna 15 during its descent, and these were released in July 2009 for the 40th anniversary of Apollo 11.[49] Personnel Prime crew Position Astronaut Neil A. Armstrong Commander Second and last spaceflight Michael Collins Command Module Pilot Second and last spaceflight Edwin \"Buzz\" E. Aldrin Jr. Lunar Module Pilot Second and"
#       }
#    },
#    {
#       "id":"c2f93a30-6c8b-e83b-21b6-e97c5a49b700",
#       "score":0.4957565,
#       "content":{
#          "text":"position of equality. A crewed mission to the Moon would serve this purpose.[24] On May 25, 1961, Kennedy addressed the United States Congress on \"Urgent National Needs\" and declared: I believe that this nation should commit itself to achieving the goal, before this decade [1960s] is out, of landing a man on the Moon and returning him safely to the Earth. No single space project in this period will be more impressive to mankind, or more important for the long-range exploration of space; and none will be so difficult or expensive to accomplish. We propose to accelerate the development of the appropriate lunar space craft. We propose to develop alternate liquid and solid fuel boosters, much larger than any now being developed, until certain which is superior. We propose additional funds for other engine development and for unmanned explorations—explorations which are particularly important for one purpose which this nation will never overlook: the survival of the man who first makes this daring flight. But in a very real sense, it will not be one man going to the Moon—if we make this judgment affirmatively, it will be an entire nation. For all of us must work to put him there. — Kennedy\\'s speech to Congress[25] On September 12, 1962, Kennedy delivered another speech before a crowd of about 40,000 people in the Rice University football stadium in Houston, Texas.[26][27] A widely quoted refrain from the middle portion of the speech reads as follows: https://en.wikipedia.org/wiki/Apollo_11 4/5119/12/2024, 11:21 Apollo 11 - Wikipedia"
#       }
#    },
#    {
#       "id":"82c5a492-66a7-48d8-16c3-b58d7dfe5ef9",
#       "score":0.48770034,
#       "content":{
#          "text":"achieved something great. Drastic cuts, warned Caspar Weinberger, the deputy director of the Office of Management and Budget, might send a signal that \"our best years are behind us\".[233] After the Apollo 11 mission, officials from the Soviet Union said landing humans on the Moon was dangerous and unnecessary. At the time the Soviet Union was attempting to retrieve lunar samples robotically. The Soviets publicly denied there was a race to the Moon, and indicated they were not making an attempt.[234] Mstislav Keldysh said in July 1969, \"We are concentrating wholly on the https://en.wikipedia.org/wiki/Apollo_11 26/5119/12/2024, 11:21 Apollo 11 - Wikipedia creation of large satellite systems.\" It was revealed in 1989 that the Soviets had tried to send people to the Moon, but were unable due to technological difficulties.[235] The public\\'s reaction in the Soviet Union was mixed. The Soviet government limited the release of information about the lunar landing, which affected the reaction. A portion of the populace did not give it any attention, and another portion was angered by it.[236] The Apollo 11 landing is referenced in the songs \"Armstrong, Aldrin and Collins\" by the Byrds on the 1969 album Ballad of Easy Rider, \"Coon on the Moon\" by Howlin\\' Wolf on the 1973 album The Back Door Wolf, and \"One Small Step\" by Ayreon on the 2000 album Universal Migrator Part 1: The Dream Sequencer. Spacecraft The command module Columbia went on a tour of the United States, visiting 49 state capitals, the District of Columbia, and Anchorage,"
#       }
#    }
# ]

Text-embedding-ada-002:

Focuses on Apollo 11’s cultural, political, and social impacts (e.g., the Space Race, racial and financial inequalities). Mentions the Apollo program as a technical achievement but lacks explicit connections to Industrial Revolution advancements like manufacturing, engineering, or related technologies.

Classification: Low Context Relevance - This result is centred more on the socio-political outcomes of Apollo 11 than on the influence of prior technological advancements.

Text-embedding-3-large:

Provides technical details about the Apollo spacecraft design and mentions technologies like semiconductors and integrated circuits used in the Apollo Guidance Computer. Indicates NASA’s reliance on advanced technology but doesn’t explicitly connect these developments to the Industrial Revolution.

Classification: Moderate Context Relevance - While it identifies key technologies in Apollo 11, the link to the Industrial Revolution is indirect.

Mini_lm_l12_v2:

Discusses Apollo 11’s technical superiority, its significance in the Space Race, and its societal implications. Makes vague references to engineering achievements but lacks detailed mention of Industrial Revolution-era technological roots.

Classification: Low Context Relevance - The focus is broad but not connected to the prompt’s specific request for Industrial Revolution influences.

Bge_multilingual_gemma2:

Includes details on Kennedy’s vision for the Apollo program and technical achievements. Offers context on engineering innovations that underpinned the Apollo mission, such as liquid and solid fuel boosters, and positions them as advancements built upon previous technologies. This result indirectly ties modern space exploration advancements to the evolution of engineering and manufacturing from the Industrial Revolution.

Classification: High Context Relevance - It addresses advancements in engineering and indirectly links these to historical technological progress, making it most relevant to the prompt.

If Shakespeare had written about the Titanic tragedy, how might he have described the events and their emotional impact?

This question also contains two subjects but more nuanced, it would be interesting for testing the LLM’s answers

Retrieve documents
prompt="If Shakespeare had written about the Titanic tragedy, how might he have described the events and their emotional impact?"

print("text-embedding-ada-002")
print(retrieve_qa_documents(client,"test-text-embedding-ada-002",prompt,"text-embedding-ada-002",openai_api_key))
print("text-embedding-3-large")
print(retrieve_qa_documents(client,"test-text-embedding-3-large",prompt,"text-embedding-3-large",openai_api_key))
print("mini_lm_l12_v2")
print(retrieve_qa_documents_v2(client,"test-mini_lm_l12_v2",prompt,"mini_lm_l12_v2",infomaniak_api_key,infomaniak_product_id))
print("bge_multilingual_gemma2")
print(retrieve_qa_documents_v2(client,"test-bge_multilingual_gemma2",prompt,"bge_multilingual_gemma2",infomaniak_api_key,infomaniak_product_id))
Output
# OUTPUT:
# ada002=[
#     {
#         'id': '6c3c6e1f-107b-2055-9363-31053b08e6bc', 
#         'score': 0.82776684,
#         'content': {
#             'text': "First Officer William Murdoch ordered the ship to be steered around the iceberg and the engines to be reversed,[159] but it was too late. The starboard side of Titanic struck the iceberg, creating a series of holes below the waterline.[j] The hull was not punctured, but rather dented such that the steel plates of the hull buckled and separated, allowing water to rush in. Five of the sixteen watertight compartments were heavily breached and a sixth was slightly compromised. It soon became clear that Titanic would sink, as the ship could not remain afloat with more than four compartments flooded. Titanic began sinking bow-first, with water spilling from compartment to compartment over the top of each watertight bulkhead as the ship's angle in the water became steeper.[161] Those aboard Titanic were ill-prepared for such an emergency. In accordance with accepted practices of the time, as ships were seen as largely unsinkable and lifeboats were intended to transfer passengers to nearby rescue vessels,[162][k] Titanic only had enough lifeboats to carry about half of those on board; if the ship had carried the full complement of about 3,339 passengers and crew, only about a third could have been accommodated in the lifeboats.[164] The crew had not been trained adequately in carrying out an evacuation. The officers did not know how many they could safely put aboard the lifeboats and launched many of them barely half-full.[165] Third-class passengers were largely left to fend for themselves, causing many of them to become trapped below"
#          }
#     }, 
#     {
#         'id': '19ced10b-dd41-0b30-6bf1-12f103dfbdd1', 
#         'score': 0.8249684, 
#         'content': {
#             'text': 'which features a 22-tonne slab of the ship\'s hull. It also runs an exhibition which travels around the world.[301] In Nova Scotia, Halifax\'s Maritime Museum of the Atlantic displays items that were recovered from the sea a few days after the disaster. They include pieces of woodwork such as panelling from the ship\'s First Class Lounge and an original deckchair,[302] as well as objects removed from the victims.[303] In 2012 the centenary was marked by plays, radio programmes, parades, exhibitions and special trips to the site of the sinking together with commemorative stamps and coins.[186][304][305][306][307] Royal Mail (whose mail was carried by RMS (Royal Mail Ship) Titanic) issued ten 1st class UK postage stamps, each with the "crown seal", to mark the centenary of the disaster.[308] https://en.wikipedia.org/wiki/Titanic 20/3519/12/2024, 09:55 Titanic - Wikipedia In a frequently commented-on literary coincidence, Morgan Robertson authored a novel called Futility in 1898 about a fictional British passenger liner with the plot bearing a number of similarities to the Titanic disaster. In the novel, the ship is SS Titan, a four-stacked liner, the largest in the world and considered unsinkable; like the Titanic, sinks in April after hitting an iceberg and does not have enough lifeboats.[309] In Northern Ireland It took many decades before the significance of Titanic was promoted in Northern Ireland, where it was built by Harland and Wolff in Belfast. While the rest of the world embraced the glory and tragedy of Titanic, it remained a taboo subject throughout the 20th century in'
#         }
#     }, 
#     {
#         'id': '4fd16457-5b83-8bb1-ccac-c85895d20e6a', 
#         'score': 0.82462573, 
#         'content': {
#             'text': 'Hamlet\'s mind:[211] Sir, in my heart there was a kind of fighting That would not let me sleep. Methought I lay Worse than the mutines in the bilboes. Rashly— And prais\'d be rashness for it—let us know Our indiscretion sometimes serves us well ... [211] — Hamlet, Act 5, Scene 2, 4–8 After Hamlet, Shakespeare varied his poetic style further, particularly in the more emotional passages of the late tragedies. The literary critic A. C. Bradley described this style as "more concentrated, rapid, varied, and, in construction, less regular, not seldom twisted or elliptical".[212] In the last phase of his career, Shakespeare adopted many techniques to achieve these effects. These included run-on lines, irregular pauses and stops, and extreme variations in sentence structure and length.[213] In Macbeth, for example, the language darts from one unrelated metaphor or simile to another: "was the hope drunk/ Wherein you dressed yourself?" (1.7.35–38); "... pity, like a naked new-born babe/ Striding the blast, or heaven\'s cherubim, hors\'d/ Upon the sightless couriers of the air ..." (1.7.21–25). The listener is challenged to complete the sense.[213] The late romances, with their shifts in time and surprising turns of plot, inspired a last poetic style in which long and short sentences are set against one another, clauses are piled up, subject and object are reversed, and words are omitted, creating an effect of spontaneity.[214] https://en.wikipedia.org/wiki/William_Shakespeare 11/2919/12/2024, 11:23 William Shakespeare - Wikipedia Shakespeare combined poetic genius with a practical sense of the theatre.[215] Like all playwrights of the'
#         }
#     }
# ]
# tree_large=[
#     {
#         'id': 'a0554554-f358-a5d7-05ee-16af998182d7', 
#         'score': 0.5322938, 
#         'content': {
#             'text': 'time, he dramatised stories from sources such as Plutarch and Holinshed.[216] He reshaped each plot to create several centres of interest and to show as many sides of a narrative to the audience as possible. This strength of design ensures that a Shakespeare play can survive translation, cutting, and wide interpretation without loss to its core drama.[217] As Shakespeare\'s mastery grew, he gave his characters clearer and more varied motivations and distinctive patterns of speech. He preserved aspects of his earlier style in the later plays, however. In Shakespeare\'s late romances, he deliberately returned to a more artificial style, which emphasised the illusion of theatre.[218][219] Legacy Influence Shakespeare\'s work has made a significant and lasting impression on later theatre and literature. In particular, he expanded the dramatic potential of characterisation, plot, language, and genre.[220] Until Romeo and Juliet, for example, romance had not been viewed as a worthy topic for tragedy.[221] Soliloquies had been used mainly to convey information about characters or events, but Shakespeare used them to explore characters\' minds.[222] His work heavily influenced later poetry. The Romantic poets attempted to revive Shakespearean verse drama, though with little success. Critic George Steiner described all English verse dramas from Coleridge to Tennyson as "feeble variations on Shakespearean themes."[223] John Milton, Macbeth Consulting the considered by many to be the most important English poet after Vision of the Armed Head. By Henry Fuseli, 1793– Shakespeare, wrote in tribute: "Thou in our wonder and 1794. astonishment/ Hast built thyself a live-long monument."[224]'
#         }
#     }, 
#     {
#         'id': 'ca964955-d60a-5b6c-5d51-6ec23c0d0b01', 
#         'score': 0.5271486, 
#         'content': {
#             'text': 'or flaws, which Fuseli, 1780–1785. overturn order and destroy the hero and those he loves.[140] In Othello, Iago stokes Othello\'s sexual jealousy to the point where he murders the innocent wife who loves him.[141][142] In King Lear, the old king commits the tragic error of giving up his powers, initiating the events which lead to the torture and blinding of the Earl of Gloucester and the murder of Lear\'s youngest daughter, Cordelia. According to the critic Frank Kermode, "the play...offers neither its good characters nor its audience any relief from its cruelty".[143][144][145] In Macbeth, the shortest and most compressed of Shakespeare\'s tragedies,[146] uncontrollable ambition incites Macbeth and his wife, Lady Macbeth, to murder the rightful king and usurp the throne until their own guilt destroys them in turn.[147] In this play, Shakespeare adds a supernatural element to the tragic structure. His last major tragedies, Antony and Cleopatra and Coriolanus, contain some of Shakespeare\'s finest poetry and were considered his most successful tragedies by the poet and critic T. S. Eliot.[148][149][150] Eliot wrote, "Shakespeare acquired more essential history from Plutarch than most men could from the whole British Museum."[151] In his final period, Shakespeare turned to romance or tragicomedy and completed three more major plays: Cymbeline, The Winter\'s Tale, and The Tempest, as well as the collaboration, Pericles, Prince of Tyre. Less bleak than the tragedies, these four plays are graver in tone than the comedies https://en.wikipedia.org/wiki/William_Shakespeare 7/2919/12/2024, 11:23 William Shakespeare - Wikipedia of the 1590s, but they end with reconciliation'
#         }
#     }, 
#     {
#         'id': 'fed5af4d-9412-65d2-f9e2-1ae565120cb2', 
#         'score': 0.5235987, 
#         'content': {
#             'text': 'the histories of the Oberon, Titania and Puck with late 1590s, Henry IV, Part 1 and 2, and Henry V. Henry IV Fairies Dancing. By William Blake, features Falstaff, rogue, wit and friend of Prince Hal. His c. 1786. characters become more complex and tender as he switches deftly between comic and serious scenes, prose and poetry, and achieves the narrative variety of his mature work.[128][129][130] This period begins and ends with two tragedies: Romeo and Juliet, the famous romantic tragedy of sexually charged adolescence, love, and death;[131][132] and Julius Caesar—based on Sir Thomas North\'s 1579 translation of Plutarch\'s Parallel Lives—which introduced a new kind of drama.[133][134] According to Shakespearean scholar James Shapiro, in Julius Caesar, "the various strands of politics, character, inwardness, contemporary events, even Shakespeare\'s own reflections on the act of writing, began to infuse each other".[135] In the early 17th century, Shakespeare wrote the so-called "problem plays" Measure for Measure, Troilus and Cressida, and All\'s Well That Ends Well and a number of his best known tragedies.[136][137] Many critics believe that Shakespeare\'s tragedies represent the peak of his art. Hamlet has probably been analysed more than any other Shakespearean character, especially for his famous soliloquy which begins "To be or not to be; that is the question".[138] Unlike the introverted Hamlet, whose fatal flaw is hesitation, Othello and Lear are undone by Hamlet, Horatio, Marcellus, and the hasty errors of judgement.[139] The plots of Shakespeare\'s Ghost of Hamlet\'s Father. Henry tragedies often hinge on such fatal errors'
#         }
#     }
# ]
# mini_lm_l12_v2=[
#     {
#         'id': 'a0554554-f358-a5d7-05ee-16af998182d7', 
#         'score': 0.491459, 
#         'content': {
#             'text': 'time, he dramatised stories from sources such as Plutarch and Holinshed.[216] He reshaped each plot to create several centres of interest and to show as many sides of a narrative to the audience as possible. This strength of design ensures that a Shakespeare play can survive translation, cutting, and wide interpretation without loss to its core drama.[217] As Shakespeare\'s mastery grew, he gave his characters clearer and more varied motivations and distinctive patterns of speech. He preserved aspects of his earlier style in the later plays, however. In Shakespeare\'s late romances, he deliberately returned to a more artificial style, which emphasised the illusion of theatre.[218][219] Legacy Influence Shakespeare\'s work has made a significant and lasting impression on later theatre and literature. In particular, he expanded the dramatic potential of characterisation, plot, language, and genre.[220] Until Romeo and Juliet, for example, romance had not been viewed as a worthy topic for tragedy.[221] Soliloquies had been used mainly to convey information about characters or events, but Shakespeare used them to explore characters\' minds.[222] His work heavily influenced later poetry. The Romantic poets attempted to revive Shakespearean verse drama, though with little success. Critic George Steiner described all English verse dramas from Coleridge to Tennyson as "feeble variations on Shakespearean themes."[223] John Milton, Macbeth Consulting the considered by many to be the most important English poet after Vision of the Armed Head. By Henry Fuseli, 1793– Shakespeare, wrote in tribute: "Thou in our wonder and 1794. astonishment/ Hast built thyself a live-long monument."[224]'
#         }
#     }, 
#     {
#         'id': '150c70f5-cc9c-31af-df95-aa1c96cd5956', 
#         'score': 0.4722919, 
#         'content': {
#             'text': 'setting, combined with the Jacobean fashion for lavishly staged masques, allowed Shakespeare to https://en.wikipedia.org/wiki/William_Shakespeare 8/2919/12/2024, 11:23 William Shakespeare - Wikipedia introduce more elaborate stage devices. In Cymbeline, for example, Jupiter descends "in thunder and lightning, sitting upon an eagle: he throws a thunderbolt. The ghosts fall on their knees."[175][176] The actors in Shakespeare\'s company included the famous Richard Burbage, William Kempe, Henry Condell and John Heminges. Burbage played the leading role in the first performances of many of Shakespeare\'s plays, including The reconstructed Globe Theatre on Richard III, Hamlet, Othello, and King Lear.[177] The popular the south bank of the River Thames comic actor Will Kempe played the servant Peter in Romeo and in London Juliet and Dogberry in Much Ado About Nothing, among other characters.[178][179] He was replaced around 1600 by Robert Armin, who played roles such as Touchstone in As You Like It and the fool in King Lear.[180] In 1613, Sir Henry Wotton recorded that Henry VIII "was set forth with many extraordinary circumstances of pomp and ceremony".[181] On 29 June, however, a cannon set fire to the thatch of the Globe and burned the theatre to the ground, an event which pinpoints the date of a Shakespeare play with rare precision.[181] Textual sources In 1623, John Heminges and Henry Condell, two of Shakespeare\'s friends from the King\'s Men, published the First Folio, a collected edition of Shakespeare\'s plays. It contained 36 texts, including 18 printed for the first time.[182] The others had already appeared in quarto'
#         }
#     }, 
#     {
#         'id': '531ecdfa-ec8a-2d5a-c6f5-440c8cde47c3', 
#         'score': 0.47223628, 
#         'content': {
#             'text': "Shakespeare influenced novelists such as Thomas Hardy, William Faulkner, and Charles Dickens. The American novelist Herman Melville's soliloquies owe much to Shakespeare; his Captain Ahab in Moby-Dick is a classic tragic hero, inspired by King Lear.[225] Scholars have identified 20,000 pieces of music linked to Shakespeare's works, including Felix Mendelssohn's overture and incidental music for A Midsummer Night's Dream and Sergei Prokofiev's ballet Romeo and Juliet. His work has inspired several operas, among them Giuseppe Verdi's Macbeth, Otello and Falstaff, whose critical standing compares with that of the source plays.[226] Shakespeare has also inspired many painters, including the Romantics and the Pre- Raphaelites, while William Hogarth's 1745 painting of actor David Garrick playing Richard III was decisive in establishing the genre of theatrical portraiture in Britain.[227] The Swiss Romantic artist Henry Fuseli, a friend of William Blake, even translated Macbeth into German.[228] The psychoanalyst Sigmund Freud drew on Shakespearean psychology, in particular, that of Hamlet, for his theories of human nature.[229] Shakespeare has been a rich source for filmmakers; Akira Kurosawa adapted Macbeth and King Lear as Throne of Blood and Ran, respectively. Other examples of Shakespeare on film include Max Reinhardt's A Midsummer Night's Dream, Laurence Olivier's Hamlet and Al Pacino's documentary Looking For Richard.[230] Orson Welles, a lifelong lover of Shakespeare, directed and starred in Macbeth, Othello and Chimes at Midnight, in which he plays John Falstaff, which Welles himself called his best work.[231] https://en.wikipedia.org/wiki/William_Shakespeare 12/2919/12/2024, 11:23 William Shakespeare - Wikipedia In Shakespeare's day, English grammar, spelling, and"
#         }
#     }
# ]
# bge_multilingual_gemma2=[
#     {
#         'id': '9464c805-6c0d-eb02-cc53-be2e50fcdbb1', 
#         'score': 0.56913245, 
#         'content': {
#             'text': "were sent by wireless, rockets, and lamp, but none of the ships that responded were near enough to reach Titanic before sinking.[172] A radio operator on board SS Birma, for instance, estimated that it would be 6 am before the liner could arrive at the scene. Meanwhile, SS Californian, which was the last to have been in contact before the collision, saw Titanic's flares but failed to assist.[173] Around 4 am, RMS Carpathia arrived on the scene in response to Titanic's earlier distress calls.[174] https://en.wikipedia.org/wiki/Titanic 13/3519/12/2024, 09:55 Titanic - Wikipedia When the ship sank, the lifeboats that had been lowered were only filled up to an average of 60%.[175] 706 people survived the disaster and were conveyed by Carpathia to New York, Titanic's original destination, while 1,517 people died.[108] Aftermath of sinking Immediate aftermath RMS Carpathia took three days to reach New York after leaving the scene of the disaster with a journey slowed by pack ice, fog, thunderstorms and rough seas.[179] Carpathia was, however, able to pass news to the outside world by wireless about what had happened. The initial reports were confusing, leading the American press to report erroneously on 15 April that Titanic was being towed to port by SS Virginian.[180] Late on the night of 15 April White Star reported a message was received saying Titanic had sunk, but all passengers and crew had been transferred to another vessel.[181] Later that day, confirmation came through that Titanic had been lost and that most of the passengers"
#             }
#     }, 
#     {
#         'id': '4351c234-bbf9-402f-1227-6d0e821ca7f0', 
#         'score': 0.5386289, 
#         'content': {
#             'text': "were listing. At 2:15 am, Lord was notified that the ship could no longer be seen. Lord asked again if the lights had had any colours in them, and he was informed that they were all white.[227] Californian eventually responded. At around 5:30 am, Chief Officer George Stewart awakened wireless operator Cyril Furmstone Evans, informed him that rockets had been seen during the night, and asked that he try to communicate with any ship. He got news of Titanic's loss, Captain Lord was notified, and the ship set out to render assistance, arriving well after Carpathia had already picked up all the survivors.[228] The inquiries found that the ship seen by Californian was in fact Titanic and that it would have been possible for Californian to aid rescue; therefore, Captain Lord had acted improperly in failing to do so.[229][n] Survivors and victims The number of casualties of the sinking is unclear, because of a number of factors. These include confusion over the passenger list, which included some names of people who cancelled their trip at the last minute, and the fact that several passengers travelled under aliases for various reasons and were therefore double-counted on the casualty lists.[231] The death toll has been put at between 1,490 and 1,635 people.[232] The tables below use figures from the British Board of Trade https://en.wikipedia.org/wiki/Titanic 16/3519/12/2024, 09:55 Titanic - Wikipedia report on the disaster.[108] While the use of the Marconi wireless system did not achieve the result of bringing a rescue ship to"
#             }
#     }, 
#     {
#         'id': '42ddc0a2-7e07-4c37-86d8-9a37df332e6b', 
#         'score': 0.53250146, 
#         'content': {
#             'text': 'available to send passenger "marconigrams" and for History the ship\'s operational use. Titanic had advanced safety features, such United Kingdom as watertight compartments and remotely activated watertight doors, which contributed to the ship\'s reputation as "unsinkable". Name RMS Titanic Namesake Titans Titanic was equipped with 16 lifeboat davits, each capable of lowering Owner White Star Line three lifeboats, for a total capacity of 48 boats. Despite this capacity, the ship was scantly equipped with a total of only 20 lifeboats. Operator White Star Line Fourteen of these were regular lifeboats, two were cutter lifeboats, and Port of Liverpool, England four were collapsible and proved difficult to launch while the ship was registry sinking. Together, the 20 lifeboats could hold 1,178 people — roughly Route Southampton to New York City half the number of passengers on board, and a third of the number the Ordered 17 September 1908 passengers the ship could have carried at full capacity (a number Builder Harland and Wolff, Belfast consistent with the maritime safety regulations of the era). The British Cost £1.5 million (£180 million in 2023) Board of Trade\'s regulations required 14 lifeboats for a ship 10,000 tonnes. Titanic carried six more than required, allowing 338 extra Yard number 401 people room in lifeboats. When the ship sank, the lifeboats that had Way number 400 been lowered were only filled up to an average of 60%. Laid down 31 March 1909 Launched 31 May 1911 Background Completed 2 April 1912 Maiden 10 April 1912 The'
#             }
#     }
# ]

Text-embedding-ada-002:

Provides a detailed factual recount of the Titanic disaster, focusing on technical events, such as damage to the ship, lifeboat insufficiencies, and the sinking process. It lacks stylistic elements reminiscent of Shakespeare.

Classification: Moderate Context Relevance - Though not Shakespearean in tone, it contains the essential historical facts needed to discuss the Titanic. The factual narrative gives the system concrete information to work with.

Text-embedding-3-large:

Delves into Shakespeare’s writing techniques, including his use of soliloquies, dramatic potential, and his influence on literature. This result focuses on his stylistic and thematic contributions rather than the Titanic itself

Classification: Low Context Relevance - Useful for background on Shakespeare’s style but doesn’t connect with the Titanic tragedy

Mini_lm_l12_v2:

Similar to RESULT2, this focuses on Shakespeare’s legacy, stylistic elements, and their influence across literature and other media like opera and film. There are no references to Titanic or any integration of his style with the tragedy.

Classification: Low Context Relevance - Provides general background on Shakespeare’s works and influence. Least relevant to the specific task of describing Titanic in Shakespearean terms

Bge_multilingual_gemma2:

Focuses on the Titanic’s distress signals, survivor statistics, and immediate aftermath. It does not incorporate any stylistic or emotional elements akin to Shakespeare.

Classification: Moderate Context Relevance - Provides essential post-disaster information that can inform emotional or survivor-based aspects of a Shakespearean response

Conclusion

Here’s a ranking of the findings based on context relevance for each question in a markdown table:

Here is a combined table with one row per model, summarizing the context relevance for all three questions:

Model Apollo 11 & indust. revolution Shakespeare and Titanic Relativity and Time Travel Overall Context Relevance
Bge_multilingual_gemma2 High Context Relevance Moderate Context Relevance Moderate Context Relevance Moderate-High
Text-embedding-3-large Moderate Context Relevance Low Context Relevance Low Context Relevance (worst) Low-Moderate
Text-embedding-ada-002 Low Context Relevance Moderate Context Relevance Low Context Relevance Low
Mini_lm_l12_v2 Low Context Relevance Low Context Relevance Moderate Context Relevance Low-Moderate

Answers

To test the previously defined questions and documents, we will use gpt-4o-mini-2024-07-18 (the same as gpt-4o-mini at the time of the test) as the LLM to generate answers. Minimal prompt engineering will be applied to avoid the LLM to answer with “general knowledge”, using a straightforward prompt format like the following:

f"CONTENT:\n{document_texts}\n\nUSER PROMPT:\n{prompt}\n\nbased on only the content given by the user, create an answer for the prompt"

We will then analyze the generated answers to assess which embedding type proves most effective for this specific LLM model.

The results were then analyzed by claude.ai using result1, 2, 3 and 4 instead of the embedding names to avoid bias. Fun fact: when using chatGPT for this task and adding the embedding model names in the prompt, openai models always ranked at the top

How did technological advancements from the Industrial Revolution influence space exploration efforts like Apollo 11?

Request answer based on documents
prompt="How did technological advancements from the Industrial Revolution influence space exploration efforts like Apollo 11?"

print("text-embedding-ada-002")
documents=retrieve_qa_documents(client,"test-text-embedding-ada-002",prompt,"text-embedding-ada-002",openai_api_key)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
print("text-embedding-3-large")
documents=retrieve_qa_documents(client,"test-text-embedding-3-large",prompt,"text-embedding-3-large",openai_api_key)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
print("mini_lm_l12_v2")
documents=retrieve_qa_documents_v2(client,"test-mini_lm_l12_v2",prompt,"mini_lm_l12_v2",infomaniak_api_key,infomaniak_product_id)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
print("bge_multilingual_gemma2")
documents=retrieve_qa_documents_v2(client,"test-bge_multilingual_gemma2",prompt,"bge_multilingual_gemma2",infomaniak_api_key,infomaniak_product_id)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
Output
# ### text-embedding-ada-002

# The content provided does not explicitly mention the Industrial Revolution or directly link its technological advancements to the Apollo 11 mission. However, it can be inferred that the technological achievements that allowed for the success of Apollo 11 were built upon the groundwork laid by earlier industrial advancements. The successes of the Apollo program, including Apollo 11, showcased the United States' technological superiority and emerged from a long history of engineering and scientific developments stemming from the Industrial Revolution.

# During the Industrial Revolution, advancements in machinery, materials science, and engineering principles paved the way for the complex technologies required for space exploration. For instance, innovations in thermodynamics, propulsion systems, and materials used in spacecraft were all influenced by industrial-era research and developments. The meticulous engineering and risk-taking that characterized the Apollo program were reflections of the technical capabilities and a spirit of innovation established during the Industrial Revolution.

# Additionally, the Apollo 11 mission's success can be seen as the culmination of a progressive narrative that started with the industrial capabilities of the previous centuries, leading to advancements in rocket technology, computers, and telecommunications necessary to achieve such deep space exploration. The Apollo program is frequently noted as one of humanity's greatest technical achievements, a testament to the lasting impact of earlier industrial advancements on modern engineering and exploration efforts.

# ### text-embedding-3-large

# The content provided does not explicitly discuss the influence of technological advancements from the Industrial Revolution on space exploration efforts like Apollo 11. However, it does mention significant technological developments that were crucial for the Apollo project. For instance, NASA's adoption of new advancements in semiconductor devices, specifically metal–oxide–semiconductor field-effect transistors (MOSFETs) and silicon integrated circuit (IC) chips, played a vital role in the Apollo Guidance Computer (AGC). These advancements are rooted in the broader progress in technology initiated during the Industrial Revolution.

# The Industrial Revolution laid the groundwork for modern engineering and technology, which subsequently enabled the development of sophisticated systems for space exploration. Technologies and techniques from earlier periods culminated in the innovations required for Apollo, showcasing how the legacy of the Industrial Revolution influenced later advancements in aerospace engineering and space missions.

# ### mini_lm_l12_v2

# The technological advancements from the Industrial Revolution laid a foundational framework that significantly influenced space exploration efforts like Apollo 11. Key innovations during this period facilitated the development of advanced machinery and engineering principles critical for space missions. The steam engine, as a pivotal invention of the Industrial Revolution, exemplified how harnessing energy could lead to remarkable transportation advancements, a principle that would later be applied in rocketry and aircraft design.

# Moreover, the era's emphasis on standardization and mass production, which stemmed from early industrial practices such as those illustrated by the printing press, contributed to the efficient manufacturing of components necessary for space missions. This capacity for large-scale production allowed NASA to develop complex spacecraft, such as the Saturn V rocket used in Apollo 11, in large numbers and with increased reliability.

# The concept of time-keeping and order, deeply ingrained in the industrial ethos, also had parallels in space exploration. Precise timing was essential for launching rockets and maintaining trajectories, reflecting a legacy of the Industrial Revolution’s organizational techniques. Furthermore, the advancements in communication technologies emerged from this era, enabling better coordination and data transmission during space missions.

# While Apollo 11 was a product of the mid-20th century technological landscape, it directly benefited from the cumulative knowledge and innovations fostered during the Industrial Revolution, marking an evolution from terrestrial engineering to the complexities of space exploration.

# ### bge_multilingual_gemma2

# The content provided does not directly address how technological advancements from the Industrial Revolution influenced space exploration efforts like Apollo 11. However, it is implicit that the technological capabilities established during the Industrial Revolution laid the groundwork for later innovations in aerospace technology. The advancements in engineering, materials science, and manufacturing processes that emerged during that period were crucial in developing the sophisticated spacecraft and launch systems used in the Apollo program.

# For instance, Kennedy’s commitment to pushing the boundaries of technology through efforts like the Apollo missions reflected the legacy of Industrial Revolution innovations. The systematic approach to engineering and problem-solving that characterized that era enabled significant advancements in rocket technology, spacecraft design, and electronics, all integral to the success of missions such as Apollo 11. Furthermore, the mention of developing "alternate liquid and solid fuel boosters" showcases the ongoing evolution of propulsion technology, a field that began to flourish thanks to earlier industrial advancements. 

# In summary, while the content primarily focuses on the Apollo missions and the competitive landscape of space exploration, it suggests that the foundational technologies from the Industrial Revolution were essential to achieving the ambitious goal of landing humans on the Moon.
  1. text-embedding-ada-002 : 7/10
    • Strengths: Makes clear connections between Industrial Revolution innovations and space technology. Mentions specific areas of influence (thermodynamics, propulsion, materials science). Good logical progression from industrial era to space age
    • Weaknesses: Somewhat general in its examples. Could provide more specific Industrial Revolution innovations. Relies heavily on inference rather than direct connections.
  2. text-embedding-3-large: 5/10
    • Strengths: Includes specific technical details about semiconductor technology. Acknowledges the evolutionary nature of technological development.
    • Weaknesses: Very brief and limited in scope. Only focuses on one aspect (computing). Minimal discussion of Industrial Revolution specifics. Missing clear cause-and-effect relationships
  3. mini_lm_l12_v2: 9/10
    • Strengths: Excellent specific examples (steam engine, standardization, mass production). Clear cause-and-effect relationships. Links industrial principles directly to space applications. Strong discussion of time-keeping and organizational impacts. Demonstrates understanding of how historical innovations evolved into space technology.
    • Weaknesses: Could include more specific examples from Apollo 11 itself
  4. bge_multilingual_gemma2: 6/10
    • Strengths: Acknowledges the evolutionary nature of technology. Mentions specific aspects like propulsion. Good overall framework
    • Weaknesses: Too general in its connections. Relies heavily on implicit rather than explicit links. Limited specific examples from both eras. Much of the content is about acknowledging what isn’t in the text.

If Shakespeare had written about the Titanic tragedy, how might he have described the events and their emotional impact?

Request answer based on documents
prompt="If Shakespeare had written about the Titanic tragedy, how might he have described the events and their emotional impact?"

print("text-embedding-ada-002")
documents=retrieve_qa_documents(client,"test-text-embedding-ada-002",prompt,"text-embedding-ada-002",openai_api_key)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
print("text-embedding-3-large")
documents=retrieve_qa_documents(client,"test-text-embedding-3-large",prompt,"text-embedding-3-large",openai_api_key)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
print("mini_lm_l12_v2")
documents=retrieve_qa_documents_v2(client,"test-mini_lm_l12_v2",prompt,"mini_lm_l12_v2",infomaniak_api_key,infomaniak_product_id)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
print("bge_multilingual_gemma2")
documents=retrieve_qa_documents_v2(client,"test-bge_multilingual_gemma2",prompt,"bge_multilingual_gemma2",infomaniak_api_key,infomaniak_product_id)
print(call_llm(prompt,documents,"gpt-4o-mini-2024-07-18", openai_api_key))
Output
# ### text-embedding-ada-002
# Had Shakespeare chosen to chronicle the Titanic tragedy, his portrayal might have woven intricate poetic language with deep emotional resonance. He would likely depict the grandeur of the ship, akin to the majestic castles of his time, emphasizing its proud journey across the vast ocean, only to be fatally interrupted by the icy touch of fate—an iceberg, a metaphor for the unforeseen trials that life often presents.

# In a soliloquy akin to Hamlet’s reflections, he might express the despair of those aboard, caught in the throes of panic and confusion. “What folly! To deem our vessel, grand and bejeweled, impervious to death’s cruel embrace! With hearts buoyed by dreams and burdened by hubris, we dance perilously close to the edge of the abyss,” he might lament, encapsulating the sense of invulnerability that blinded many to the looming peril.

# He could illustrate the tragic descent of the ship as a descent into chaos—“Lo! The great Titan bows, her splendor vanquished by a shivering grasp of the deep. What use now are the lifeboats, mere gossamer hopes, afloat in a tempest of human fear?” In this way, Shakespeare would evoke both the physical sinking of the ship and the emotional sinking of spirits, portraying the desperation and isolation experienced by those left behind, especially the third-class passengers.

# The aftermath would likely resonate with themes of loss and regret: “O, cruel fate! How doth it mock our fleeting joys, as the spectral cries of the lost haunt the waves, and remnants of hope drift into the embrace of the sea!” Through eloquent and vivid imagery, he would convey the profound tragedy of a society ill-prepared for disaster—a reflection on human arrogance and the painful lessons etched into memory.

# In his closing lines, he might leave the audience with a poignant contemplation on the nature of existence: “Thus do we stand, humbled before the great unknown, for in our endeavors to conquer the sea’s embrace, we may yet find ourselves ensnared in its grasp.” Such a portrayal would encapsulate the essence of Shakespeare’s style, blending the grandeur of tragedy with the introspection of the human condition.

# ### text-embedding-3-large
# Had Shakespeare penned a play about the Titanic tragedy, he would likely have employed his mastery of characterization and soliloquy to delve deeply into the emotional turmoil and human folly surrounding the disaster. He might have dramatised the events with several centres of interest, weaving together the lives of various passengers—from the wealthy elite in their gilded cabins, reveling in their hubris, to the lower-class immigrants, laden with dreams and hopes of a new life. 

# In his characteristic style, Shakespeare could have introduced a protagonist akin to a tragic hero, perhaps a captain torn between duty and ambition, whose fatal flaw would be a misplaced confidence in the ship’s invincibility. Through captivating soliloquies, this character might reflect on the weight of leadership and the fragility of human life, echoing themes of ambition and fate, reminiscent of Macbeth’s unchecked ambition or Lear’s tragic misjudgments. 

# The emotional impact would be explored not only through the catastrophe itself but also through poignant reflections on love, loss, and the irony of fate—mirroring the doomed romance of “Romeo and Juliet” with star-crossed lovers ensnared by the icy grasp of the Atlantic, their futures slipping away as rapidly as the ship sank. 

# The director's choices, the interplay of light and darkness, the chaos of the sinking ship, and the despair of those left behind would manifest through the dramatic dialogues and rich imagery typical of Shakespearean verse. It could culminate in a haunting conclusion, where the survivors grapple with their own guilt and sorrow, echoing the moral complexities found in his tragedies, and leaving the audience to ponder the question of humanity’s hubris against the merciless forces of nature. 

# Thus, Shakespeare's Titanic tragedy would resonate with themes of ambition, folly, and the ephemeral nature of life, inviting reflection on the human condition amidst a backdrop of disaster.

# ### mini_lm_l12_v2
# If Shakespeare had penned a dramatic account of the Titanic tragedy, he might have employed his characteristic richness of language and depth of character to convey the harrowing events and emotional turmoil of that fateful night. Drawing from his mastery of soliloquies, he could have provided poignant glimpses into the minds of individuals aboard the ship—captains faced with the weight of their decisions, passengers filled with hope and dread, and crew members grappling with their duty versus their humanity.

# He could have depicted the voyage itself as a metaphor for hubris, masterfully weaving themes of ambition and downfall, much like he did in "Macbeth" and "Hamlet." The ship, a grand symbol of modern achievement, would serve as a stark contrast to the chaos that eventually unfolds, echoing the duality he often explored in his characters—noble aspirations tethered to tragic flaws.

# In the climactic moments, Shakespeare might have utilized vivid imagery to portray the sinking vessel, with electric storms reflecting the inner turmoil of the characters. The cries of the doomed might be rendered in lyrical verse, evoking the sorrowful strains of lost dreams. "Alas, what folly to tempt the wrath of the deep," a character might lament, encapsulating the tragedy's inevitability.

# Subsequently, through his deft handling of multiple perspectives, he could have unfolded the impact of the disaster on those left behind—loved ones mourning in the shadows of their lost companions, their anguish a haunting echo reverberating through the annals of time. Shakespeare's exploration of human emotion would delve deep into despair, loss, and the fleeting nature of life, leaving audiences with a lingering sense of tragedy that would resonate through ages, a true testament to the power of the human spirit amidst calamity.

# ### bge_multilingual_gemma2
# Had Shakespeare penned a tragedy about the sinking of the Titanic, the narrative might unfold with the grandeur and gravitas typical of his works. The ship, a "noble vessel, proud and unsinkable," would be depicted as a character embodying humanity's hubris, destined for a cruel fate amidst the icy grasp of the North Atlantic. 

# The opening act may introduce the illustrious Titanic, sailing with great promise from Southampton to New York, filled with patrons of varying fortunes—"lords and ladies, the modest and the grand," all embraced by the glow of hope and ambition. Shakespeare would likely craft a chorus of sailors, warning of the folly in overconfidence: "A vessel girded with watertight chambers, yet not with the wisdom to heed the dark whispers of the ocean."

# As the tale unfolds, the collision with the iceberg would be dramatized with poetic tension, perhaps reminiscent of his tragic heroes grappling with fate. The audience would witness the chaos and despair as the ship strikes the fatal blow, "the heart of the sea piercing the heart of this mighty ship." The emotions would swell as passengers scramble, the stage filled with "the cries of the damned," a cacophony reflecting their desperation and fear, echoing through the night.

# In the aftermath, Shakespeare would explore themes of sacrifice and survival through the lifeboats, filled "but to an average of sixty percent," painting a poignant picture of the human condition—some saved, many lost. Monologues would reflect the inner turmoil of those who remained behind, clinging to the promise of deliverance that never came, their hopes extinguished as "the cruel waves claim their due." A heart-wrenching lamentation would echo across the stage, contemplating the randomness of life and death, "as the grim reaper cuts down the noble and the wretched alike."

# The arrival of the RMS Carpathia would serve as a bittersweet resolution, offering salvation to the few while the sea preserves the memories of the many. In a final act, a reflection on the arbitrary nature of fate and the enduring spirit of those who perished might be expressed, leaving the audience to ponder, long after the curtain falls, the delicate balance between man's aspirations and the indifferent force of nature. 

# Thus, through Shakespeare's eloquent pen, the Titanic tragedy would transform into a timeless tale of human folly, resilience, and the somber reflection on lives intertwined in a fleeting moment of history.
  1. text-embedding-ada-002: 8/10
    • Strengths: Excellent use of Shakespearean language and devices like soliloquies. Strong metaphorical connections between the ship’s physical and emotional descent. Rich imagery that feels authentic to Shakespeare’s style. Effectively captures themes of hubris and human frailty.
    • Weaknesses: Could have developed more specific character perspectives. Slightly overuses exclamations.
  2. text-embedding-3-large: 7/10
    • Strengths: Good focus on dramatic structure and character development. Strong parallels to existing Shakespearean works. Thoughtful inclusion of class dynamics. Solid exploration of theatrical elements
    • Weaknesses: Less poetic language compared to other responses. More analytical than emotionally resonant. Could have included more specific imagery.
  3. mini_lm_l12_v2: 6/10
    • Strengths: Good connection to Shakespeare’s existing works. Solid understanding of theatrical elements. Nice inclusion of weather imagery
    • Weaknesses: More general and less specific than other responses. Limited use of Shakespearean language. Could have developed the emotional aspects more deeply.
  4. bge_multilingual_gemma2: 9/10
    • Strengths: Excellent structural understanding of Shakespearean drama. Rich, period-appropriate language, and imagery. Strong narrative arc from beginning to end. Effective use of specific details (like “sixty percent” in lifeboats). Balanced mix of grand themes and intimate human moments. Clever inclusion of a chorus. Powerful closing reflection that ties everything together
    • Weaknesses: Could have included more direct dialogue between characters

Conclusion

Here is a summary of the grading results presented in a table. The analysis shows that bge_multilingual_gemma2 achieved the highest overall average of 8/10, performing exceptionally well with two top scores (9/10) and maintaining solid performance across all categories.

model Apollo11 & industrial revolution Shakespeare & titanic Relativity and Doctor Who total
text-embedding-ada-002 7/10 8/10 8/10 7.6/10
text-embedding-3-large 5/10 7/10 7/10 6.3/10
mini_lm_l12_v2 4/10 6/10 5/10 5/10
bge_multilingual_gemma2 6/10 9/10 9/10 8/10