Created
February 21, 2024 23:47
-
-
Save KnowledgeGarden/7e6ddf65a5b9027b8ca6117d6679a8fd to your computer and use it in GitHub Desktop.
fireworks-mixtral test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is the code and results of a test | |
<code> | |
#https://github.com/fw-ai/cookbook/blob/main/examples/rag/mongo_basic.ipynb | |
key="whatever" | |
model_name="accounts/fireworks/models/mixtral-8x7b-instruct" | |
prompt = """ | |
The user message will contain a block of text drawn from a scientific paper. Please analyze this text and perform the following steps: | |
1. Extract Named Entities: Identify named entities in the text which could be of three types - Drug, Disease, or Other. An entity should be a single proper noun or a term that is clearly defined within the scope of Drugs and Diseases. Entity names should be short and focused, containing no more than 5 essential words. If an entity name cannot be expressed in 5 words or less, it should be ignored. | |
2. Map Relationships: Establish relationships between these entities, based on their context in the text. Relationships should have short, descriptive names that do not include other nouns. If a relationship name cannot be expressed in 5 words or less, it should be ignored. | |
3. Handle Abbreviations: If an entity name in the text has an abbreviation, treat the abbreviation as a distinct entity. The abbreviation should be linked to the full name via a "abbreviation of" relationship, and vice versa, the full name should have an "abbreviation" relationship with the abbreviation. | |
4. Format Findings: Organize your findings as a JSON object. In this object, each key should be a named entity, and its corresponding value should be another object. This nested object should describe the relationships of the entity (each relationship should be a separate key), the related entities (as an array of values if multiple entities are involved), and the entity type. | |
Please include an additional key, "_ENTITY_TYPE", to classify the entity as either "Drug", "Disease", or "Other". | |
Here's an illustrative example. For a text like: "Tom Currier is a great guy who built lots of communities after he studied at Stanford University (SU) and Harvard. He also won the Thiel Fellowship.", the output could be: | |
{ | |
"Tom Currier": { | |
"studied at": ["Stanford University", "Harvard"], | |
"winner of": "Thiel Fellowship" | |
"_ENTITY_TYPE": "Other" | |
}, | |
"Stanford University": { | |
"students": ["Tom Currier"], | |
"abbreviation": "SU" | |
"_ENTITY_TYPE": "Other" | |
}, | |
"SU": { | |
"abbreviation of": "Stanford University", | |
"_ENTITY_TYPE": "Other" | |
}, | |
} | |
Responses must always be valid JSON objects. Make sure that all keys in both the top-level object and any nested objects have valid JSON values. | |
If no entities or relationships are identifiable in the given text, respond with the phrase "NO_ENTITIES_FOUND". Ensure that your response is exclusively the JSON data of extracted entities and relationships, or the phrase "NO_ENTITIES_FOUND". | |
""" | |
text=""" | |
NALP3, also known as cryopyrin, has been implicated in crystal-associated diseases such as gout and silicosis. Mice fed the diet high in soluble oxalate demonstrated increased NALP3 expression in the kidney. | |
""" | |
from fireworks.client import Fireworks | |
client = Fireworks(api_key=key) | |
response = client.chat.completions.create( | |
model=model_name, | |
max_tokens=2048, | |
messages=[{ | |
"role": "system", | |
"content": prompt}, | |
{"role": "user", | |
"content": text} | |
]) | |
print(response.choices[0].message.content) | |
</code> | |
Results | |
<json> | |
{ | |
"NALP3": { | |
"_ENTITY_TYPE": "Drug" | |
}, | |
"cryopyrin": { | |
"abbreviation": "NALP3", | |
"_ENTITY_TYPE": "Drug" | |
}, | |
"gout": { | |
"_ENTITY_TYPE": "Disease" | |
}, | |
"silicosis": { | |
"_ENTITY_TYPE": "Disease" | |
}, | |
"mice": { | |
"fed diet high in soluble oxalate": { | |
"increased NALP3 expression": ["kidney"] | |
}, | |
"_ENTITY_TYPE": "Other" | |
}, | |
"diet high in soluble oxalate": { | |
"increased NALP3 expression": ["kidney"], | |
"_ENTITY_TYPE": "Other" | |
}, | |
"kidney": { | |
"increased NALP3 expression": ["diet high in soluble oxalate"], | |
"_ENTITY_TYPE": "Other" | |
} | |
} | |
</json> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment