license: llama2
datasets:
- DehydratedWater42/semantic_relations_extraction
language:
- en
library_name: transformers
pipeline_tag: text-generation
inference: false
tags:
- math
- semantic
- extraction
- graph
- relations
- science
- synthetic
SeELLama (Semantic Extraction LLama)
Model is based on LLama2-7b and fine-tuned with the DehydratedWater42/semantic_relations_extraction
dataset.
The purpose of this model is to extract semantic relations from text in a structured way.
Simplified Example:
- Initial Text: "While there is beautiful weather outside the building, from the window we can see a car. And what's the most annoying, pigeons love to sit on that car."
- Entities: ["pigeon", "car", "building"]
- Relations between entities: {"pigeon -> car": "pigeon sits on the car", "car -> building": "car is parked outside the building"}
Note: The text example above is too short for the actual model; please use at least 500-token text segments for extraction to avoid hallucinations.
Other versions:
- Get SeELLama as Safetensors: DehydratedWater42/SeELLama
- Get SeELLama as adapter: DehydratedWater42/SeELLama-qlora-adapter
How to use it:
Template:
Use the prompt template provided below to extract relations from text. Replace <<your_text_for_extraction>>
with your selected text, ideally between 500-1500 tokens,
with an optimal range of about 800-1000 tokens. You can adjust the temperature between 0.3 and 1.0; a good starting point is between 0.6 and 0.7.
Temperatures below 0.3 may lead to never ending section_description
. The higher the temperature, the more the model will fill in the gaps in the provided text.
It was fine-tuned on scientific articles, so it will supplement missing information with general knowledge.
Model was trained on 2560 context lenght where 1000-1500 tokens where used as input text.
Below is an part of larger text. Your task is to extract information about entities and relations to the JSON format.
### Text Part to Extract From:
<<your_text_for_extraction>>
### Extracted Relations:
{
"section_description":
The JSON
opening is not necessary but it improves stability. Remember to use double {{
instead of singular '{' if you are using LangChain prompts with fstring formatting.
Quantized versions:
q2_k
: Uses Q4_K for the attention.vw and feed_forward.w2 tensors, Q2_K for the other tensors.q3_k_l
: Uses Q5_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else Q3_Kq3_k_m
: Uses Q4_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else Q3_Kq3_k_s
: Uses Q3_K for all tensorsq4_0
: Original quant method, 4-bit.q4_1
: Higher accuracy than q4_0 but not as high as q5_0. However has quicker inference than q5 models.q4_k_m
: Uses Q6_K for half of the attention.wv and feed_forward.w2 tensors, else Q4_Kq4_k_s
: Uses Q4_K for all tensorsq5_0
: Higher accuracy, higher resource usage and slower inference.q5_1
: Even higher accuracy, resource usage and slower inference.q5_k_m
: Uses Q6_K for half of the attention.wv and feed_forward.w2 tensors, else Q5_Kq5_k_s
: Uses Q5_K for all tensorsq6_k
: Uses Q8_K for all tensorsq8_0
: Almost indistinguishable from float16. High resource use and slow. Not recommended for most users.
Starter code
Extract generated json
import json
json_start = """{
"section_description":
"""
to_parse = json_start + generated_text.split(json_start)[1]
print(json.loads(to_parse))
Example:
Extracting information from Minecraft Wiki.
Initial template
Below is an part of larger text. Your task is to extract information about entities and relations to the JSON format.
### Text Part to Extract From:
Players in Survival, Adventure, or Spectator have access to the 2×2 crafting grid from their inventory screen. Small crafting recipes that are at most 2×2 can be made there. These include wooden planks, sticks, crafting tables, torches and some shapeless recipes. To craft items using a bigger grid to allow more crafting recipes, create a crafting table with 4 wooden planks, place it in the world, and press use while facing it. This brings up an interface with a larger, 3×3 crafting grid, which the player can use to craft any crafting recipe in the game. There is also a recipe book where the player can access all the crafting recipes.
Some recipes do not require their ingredients to be arranged in a specific way on the crafting grid. These are commonly known as shapeless recipes. For example, players may craft a fermented spider eye by placing its ingredients anywhere within the grid or like a flint and steel can be crafted in any orientation.
On the contrary, many recipes must have their ingredients placed in the correct relative positions on the crafting grid. These are commonly known as shaped recipes. Ingredients in shaped recipes can be ‘moved’ up, down, left, or right. They can also be flipped side-ways. For example, a 3×1 recipe, such as bread, can be made using the top, middle, or bottom row of the 3×3 grid, and a bow may be made with the strings placed on the left instead of on the right.
There are recipes that may not be moved or mirrored in this way. These are commonly known as fixed recipes. For example, dyes in banner recipes - only available in Bedrock Edition - must be specifically placed to achieve the desired pattern. Fixed recipes can be added by data packs, add-ons, or mods.
### Extracted Relations:
{
"section_description":
Result (about game):
Below is an part of larger text. Your task is to extract information about entities and relations to the JSON format.
### Text Part to Extract From:
Players in Survival, Adventure, or Spectator have access to the 2×2 crafting grid from their inventory screen. Small crafting recipes that are at most 2×2 can be made there. These include wooden planks, sticks, crafting tables, torches and some shapeless recipes. To craft items using a bigger grid to allow more crafting recipes, create a crafting table with 4 wooden planks, place it in the world, and press use while facing it. This brings up an interface with a larger, 3×3 crafting grid, which the player can use to craft any crafting recipe in the game. There is also a recipe book where the player can access all the crafting recipes.
Some recipes do not require their ingredients to be arranged in a specific way on the crafting grid. These are commonly known as shapeless recipes. For example, players may craft a fermented spider eye by placing its ingredients anywhere within the grid or like a flint and steel can be crafted in any orientation.
On the contrary, many recipes must have their ingredients placed in the correct relative positions on the crafting grid. These are commonly known as shaped recipes. Ingredients in shaped recipes can be ‘moved’ up, down, left, or right. They can also be flipped side-ways. For example, a 3×1 recipe, such as bread, can be made using the top, middle, or bottom row of the 3×3 grid, and a bow may be made with the strings placed on the left instead of on the right.
There are recipes that may not be moved or mirrored in this way. These are commonly known as fixed recipes. For example, dyes in banner recipes - only available in Bedrock Edition - must be specifically placed to achieve the desired pattern. Fixed recipes can be added by data packs, add-ons, or mods.
### Extracted Relations:
{
"section_description": "In Minecraft, players can craft items using the 2x2 crafting grid. There are some fixed recipes that require the player to place their ingredients in a specific position.",
"list_of_entities": [
"crafting recipes",
"player",
"fixed recipes",
"2x2 crafting grid",
"survival, adventure, or spectator players",
"wooden planks",
"torches",
"shaped recipes",
"small crafting recipes",
"shapeless recipes",
"wooden planks, sticks, crafting tables, torches",
"flint and steel"
],
"relations": [
{
"description": "Players have access to the 2x2 crafting grid from their inventory screen.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"player"
],
"strength": "strong"
},
{
"description": "Small crafting recipes that are at most 2x2 can be made using the 2x2 crafting grid.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"survival, adventure, or spectator players"
],
"strength": "strong"
},
{
"description": "To craft items using a bigger grid to allow more crafting recipes, create a crafting table with 4 wooden planks, place it in the world, and press use while facing it.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"wooden planks"
],
"strength": "strong"
},
{
"description": "To craft items using a bigger grid to allow more crafting recipes, create a crafting table with 4 wooden planks, place it in the world, and press use while facing it.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"crafting tables"
],
"strength": "strong"
},
{
"description": "Crafting tables allow players to make bigger crafting recipes that are not possible with the 2x2 crafting grid.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"torches",
"flint and steel",
"wooden planks"
],
"strength": "strong"
},
{
"description": "Crafting tables are used to craft items using the 2x2 crafting grid.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"wooden planks, sticks, crafting tables, torches"
],
"strength": "strong"
},
{
"description": "There are some fixed recipes that require the player to place their ingredients in a specific position.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"fixed recipes"
],
"strength": "strong"
},
{
"description": "The recipes do not require their ingredients to be arranged in a specific way on the crafting grid.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"shapeless recipes"
],
"strength": "strong"
},
{
"description": "Ingredients in shapeless recipes can be ‘moved’ up, down, left, or right.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"shaped recipes"
],
"strength": "strong"
},
{
"description": "Ingredients in shaped recipes can be flipped side-ways.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"fixed recipes"
],
"strength": "strong"
},
{
"description": "There are some fixed recipes that require the player to place their ingredients in a specific position.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"fixed recipes"
],
"strength": "strong"
},
{
"description": "The recipes can be added by data packs, add-ons, or mods.",
"source_entities": [
"crafting recipes"
],
"target_entities": [
"fixed recipes"
],
"strength": "strong"
}
]
}
Smaller example (About crafting)
Below is an part of larger text. Your task is to extract information about entities and relations to the JSON format.
### Text Part to Extract From:
Players in Survival, Adventure, or Spectator have access to the 2×2 crafting grid from their inventory screen. Small crafting recipes that are at most 2×2 can be made there. These include wooden planks, sticks, crafting tables, torches and some shapeless recipes. To craft items using a bigger grid to allow more crafting recipes, create a crafting table with 4 wooden planks, place it in the world, and press use while facing it. This brings up an interface with a larger, 3×3 crafting grid, which the player can use to craft any crafting recipe in the game. There is also a recipe book where the player can access all the crafting recipes.
### Extracted Relations:
{
"section_description": "Survival, Adventure, and Spectator players have access to the 2×2 crafting grid. However, to craft items using a bigger grid, you need to create a crafting table with wooden planks, place it in the world, and press use while facing it.",
"list_of_entities": [
"Survival",
"wooden planks",
"Spectator",
"Adventure",
"crafting grid"
],
"relations": [
{
"description": "Survival players can access the 2×2 crafting grid.",
"source_entities": [
"Survival"
],
"target_entities": [
"crafting grid"
],
"strength": "strong"
},
{
"description": "Adventure and Spectator players can also access the 2×2 crafting grid.",
"source_entities": [
"Adventure"
],
"target_entities": [
"crafting grid"
],
"strength": "strong"
},
{
"description": "To craft items using a bigger grid, you need to create a crafting table with wooden planks.",
"source_entities": [
"Spectator"
],
"target_entities": [
"crafting grid"
],
"strength": "strong"
}
]
}
Dopamine example
Below is an part of larger text. Your task is to extract information about entities and relations to the JSON format.
### Text Part to Extract From:
Dopamine is synthesized in a restricted set of cell types, mainly neurons and cells in the medulla of the adrenal glands.[23] The primary and minor metabolic pathways respectively are:
Primary: L-Phenylalanine → L-Tyrosine → L-DOPA → Dopamine[20][21]
Minor: L-Phenylalanine → L-Tyrosine → p-Tyramine → Dopamine[20][21][22]
Minor: L-Phenylalanine → m-Tyrosine → m-Tyramine → Dopamine[22][24][25]
The direct precursor of dopamine, L-DOPA, can be synthesized indirectly from the essential amino acid phenylalanine or directly from the non-essential amino acid tyrosine.[26] These amino acids are found in nearly every protein and so are readily available in food, with tyrosine being the most common. Although dopamine is also found in many types of food, it is incapable of crossing the blood–brain barrier that surrounds and protects the brain.[27] It must therefore be synthesized inside the brain to perform its neuronal activity.[27]
L-Phenylalanine is converted into L-tyrosine by the enzyme phenylalanine hydroxylase, with molecular oxygen (O2) and tetrahydrobiopterin as cofactors. L-Tyrosine is converted into L-DOPA by the enzyme tyrosine hydroxylase, with tetrahydrobiopterin, O2, and iron (Fe2+) as cofactors.[26] L-DOPA is converted into dopamine by the enzyme aromatic L-amino acid decarboxylase (also known as DOPA decarboxylase), with pyridoxal phosphate as the cofactor.[26]
Dopamine itself is used as precursor in the synthesis of the neurotransmitters norepinephrine and epinephrine.[26] Dopamine is converted into norepinephrine by the enzyme dopamine β-hydroxylase, with O2 and L-ascorbic acid as cofactors.[26] Norepinephrine is converted into epinephrine by the enzyme phenylethanolamine N-methyltransferase with S-adenosyl-L-methionine as the cofactor.[26]
Some of the cofactors also require their own synthesis.[26] Deficiency in any required amino acid or cofactor can impair the synthesis of dopamine, norepinephrine, and epinephrine.[26]
Degradation
Dopamine is broken down into inactive metabolites by a set of enzymes—monoamine oxidase (MAO), catechol-O-methyl transferase (COMT), and aldehyde dehydrogenase (ALDH), acting in sequence.[28] Both isoforms of monoamine oxidase, MAO-A and MAO-B, effectively metabolize dopamine.[26] Different breakdown pathways exist but the main end-product is homovanillic acid (HVA), which has no known biological activity.[28] From the bloodstream, homovanillic acid is filtered out by the kidneys and then excreted in the urine.[28] The two primary metabolic routes that convert dopamine into HVA are:[29]
Dopamine → DOPAL → DOPAC → HVA – catalyzed by MAO, ALDH, and COMT respectively
Dopamine → 3-Methoxytyramine → HVA – catalyzed by COMT and MAO+ALDH respectively
In clinical research on schizophrenia, measurements of homovanillic acid in plasma have been used to estimate levels of dopamine activity in the brain. A difficulty in this approach however, is separating the high level of plasma homovanillic acid contributed by the metabolism of norepinephrine.[30][31]
Although dopamine is normally broken down by an oxidoreductase enzyme, it is also susceptible to oxidation by direct reaction with oxygen, yielding quinones plus various free radicals as products.[32] The rate of oxidation can be increased by the presence of ferric iron or other factors. Quinones and free radicals produced by autoxidation of dopamine can poison cells, and there is evidence that this mechanism may contribute to the cell loss that occurs in Parkinson's disease and other conditions.[33]
### Extracted Relations:
{
"section_description": "Dopamine is a neurotransmitter that plays a crucial role in regulating movement, motivation, and reward processing. It is produced in several regions of the brain, including the substantia nigra, ventral tegmental area, and hypothalamus. Dopamine is involved in several physiological functions such as motor control, cognition, and emotional responses. Low levels of dopamine have been linked to several neurological disorders, including Parkinson's disease, schizophrenia, and addiction. Dopamine is also involved in the reward system, which is responsible for motivation and pleasure. The brain's reward system is activated by the release of dopamine in response to pleasurable experiences, such as eating, sex, and drugs. Dopamine is synthesized from the amino acid L-tyrosine, which is derived from dietary sources. The primary precursor of dopamine is L-DOPA, which is synthesized from L-tyrosine by the enzyme tyrosine hydroxylase. Dopamine is then converted into norepinephrine and epinephrine by the enzyme dopamine β-hydroxylase. Dopamine is broken down into inactive metabolites by a set of enzymes, including monoamine oxidase (MAO), catechol-O-methyl transferase (COMT), and aldehyde dehydrogenase (ALDH). The two primary metabolic routes that convert dopamine into HVA are: Dopamine → DOPAL → DOPAC → HVA - catalyzed by MAO, ALDH, and COMT respectively Dopamine → 3-Methoxytyramine → HVA - catalyzed by COMT and MAO+ALDH respectively In clinical research on schizophrenia, measurements of homovanillic acid in plasma have been used to estimate levels of dopamine activity in the brain. A difficulty in this approach however, is separating the high level of plasma homovanillic acid contributed by the metabolism of norepinephrine. Dopamine is also susceptible to oxidation by direct reaction with oxygen, yielding quinones plus various free radicals as products. The rate of oxidation can be increased by the presence of ferric iron or other factors. Quinones and free radicals produced by autoxidation of dopamine can poison cells, and there is evidence that this mechanism may contribute to the cell loss that occurs in Parkinson's disease and other conditions. ",
"list_of_entities": [
"motivation",
"Parkinson's disease",
"cognition",
"pleasure",
"dopamine",
"L-tyrosine",
"schizophrenia",
"emotional responses",
"L-DOPA",
"dopamine β-hydroxylase",
"dopamine β-hydroxylase",
"L-DOPA",
"dopamine",
"L-tyrosine",
"dopamine β-hydroxylase",
"L-DOPA",
"L-tyrosine",
"L-DOPA",
"dopamine",
"L-DOPA",
"dopamine"
],
"relations": [
{
"description": "Dopamine is synthesized from the amino acid L-tyrosine, which is derived from dietary sources.",
"source_entities": [
"dopamine"
],
"target_entities": [
"L-tyrosine"
]
},
{
"description": "The primary precursor of dopamine is L-DOPA, which is synthesized from L-tyrosine by the enzyme tyrosine hydroxylase.",
"source_entities": [
"L-DOPA"
],
"target_entities": [
"dopamine"
]
},
{
"description": "Dopamine is then converted into norepinephrine and epinephrine by the enzyme dopamine β-hydroxylase.",
"source_entities": [
"dopamine"
],
"target_entities": [
"dopamine β-hydroxylase"
]
},
{
"description": "Dopamine is broken down into inactive metabolites by a set of enzymes, including monoamine oxidase (MAO), catechol-O-methyl transferase (COMT), and aldehyde dehydrogenase (ALDH).",
"source_entities": [
"dopamine"
],
"target_entities": [
"monoamine oxidase (MAO)",
"catechol-O-methyl transferase (COMT)",
"aldehyde dehydrogenase (ALDH)"
]
},
{
"description": "The two primary metabolic routes that convert dopamine into HVA are: Dopamine → DOPAL → DOPAC → HVA - catalyzed by MAO, ALDH, and COMT respectively Dopamine → 3-Methoxytyramine → HVA - catalyzed by COMT and MAO+ALDH respectively",
"source_entities": [
"dopamine"
],
"target_entities": [
"HVA",
"MAO",
"ALDH",
"COMT"
]
},
{
"description": "In clinical research on schizophrenia, measurements of homovanillic acid in plasma have been used to estimate levels of dopamine activity in the brain.",
"source_entities": [
"dopamine"
],
"target_entities": [
"homovanillic acid"
]
},
{
"description": "A difficulty in this approach however, is separating the high level of plasma homovanillic acid contributed by the metabolism of norepinephrine.",
"source_entities": [
"homovanillic acid"
],
"target_entities": [
"norepinephrine"
]
},
{
"description": "Dopamine is also susceptible to oxidation by direct reaction with oxygen, yielding quinones plus various free radicals as products.",
"source_entities": [
"dopamine"
],
"target_entities": [
"oxidation"
]
},
{
"description": "The rate of oxidation can be increased by the presence of ferric iron or other factors.",
"source_entities": [
"dopamine"
],
"target_entities": [
"ferric iron"
]
},
{
"description": "Quinones and free radicals produced by autoxidation of dopamine can poison cells, and there is evidence that this mechanism may contribute to the cell loss that occurs in Parkinson's disease and other conditions.",
"source_entities": [
"dopamine"
],
"target_entities": [
"cell loss"
]
}
]
}
Longer example (dirt block)
Below is an part of larger text. Your task is to extract information about entities and relations to the JSON format.
### Text Part to Extract From:
Usage
Using bone meal on grass blocks causes short grass, tall grass,[Java Edition only] ferns,[Bedrock Edition only] and flowers to grow.
Passive mobs tend to wander toward grass blocks. They also wander toward light.
When a sheep eats a grass block, the block becomes dirt, and a sheared sheep regrows its wool. Baby sheep graze grass much more often than adults and mature 1 minute faster when grazing.
Tilling a grass block with a hoe converts it to a farmland block.
Dirt paths can be created by using any type of shovel on the side or top of a grass block with air above it. The shovel loses 1 durability for each dirt path block created.
Death
Grass dies and changes to dirt a random time (when a random tick lands on the block) after it has been covered by any opaque blocks. Transparent blocks can kill grass in a similar manner if they cause the light level above the grass block to be four or below (like water does), and the surrounding area is not otherwise sufficiently illuminated.
Spawning
In Java Edition, animals occasionally spawn on grass blocks that have light level 9 or brighter in the space directly above. This is quite rare and requires that there be few other animals nearby or in the spawn chunks. Most animals are instead created along with the terrain.
In Bedrock Edition, most animals require surface grass blocks (grass blocks with no solid block anywhere above them at the same x, z coordinate) to spawn. Animals regularly spawn in most Overworld biomes on surface grass blocks that have light level 7 or brighter in the space directly above.
Snowy grass block
A snowy grass block with snow on top of it.
Grass blocks turn into a snowy grass block if snow, powder snow or a snow block is placed on top of the block. Removing the snow layer turns the block into a normal grass block.
Composting
In Bedrock Edition, placing grass blocks into a composter has a 30% chance of raising the compost level by 1.
### Extracted Relations:
{
"section_description": "The article discusses the various ways in which grass blocks can be used in Minecraft, including as food, fuel, and protection. It also covers how grass blocks can be used to tame animals, and the dangers of being exposed to grass. The article concludes by highlighting the importance of knowing how to use and defend against grass blocks.",
"list_of_entities": [
"dirt",
"Minecraft",
"light level",
"animal",
"surface grass blocks",
"Bedrock Edition",
"Java Edition",
"dirt path",
"grass",
"snow",
"snowy grass block",
"opaque blocks",
"sheep",
"composter",
"transparent blocks"
],
"relations": [
{
"description": "Grass blocks are a renewable resource that can be used as a food item.",
"source_entities": [
"Minecraft",
"grass"
],
"target_entities": [
"animal",
"surface grass blocks"
],
"strength": "strong"
},
{
"description": "Grass blocks can be used to tame animals.",
"source_entities": [
"Minecraft",
"grass"
],
"target_entities": [
"animal",
"surface grass blocks"
],
"strength": "strong"
},
{
"description": "Exposure to grass blocks can cause damage to the player's health.",
"source_entities": [
"Minecraft"
],
"target_entities": [
"grass",
"player"
],
"strength": "strong"
},
{
"description": "Placing grass blocks in a composter has a 30% chance of raising the compost level by 1.",
"source_entities": [
"Minecraft",
"grass"
],
"target_entities": [
"composter",
"grass"
],
"strength": "strong"
},
{
"description": "Surface grass blocks are the only ones that can be used to spawn animals.",
"source_entities": [
"Minecraft"
],
"target_entities": [
"surface grass blocks",
"animal"
],
"strength": "strong"
},
{
"description": "Animals regularly spawn in most Overworld biomes on surface grass blocks that have light level 7 or brighter in the space directly above.",
"source_entities": [
"Minecraft"
],
"target_entities": [
"surface grass blocks",
"animal"
],
"strength": "strong"
},
{
"description": "If you walk into the grass without first getting rid of any animals or monsters that are there, they will attack you.",
"source_entities": [
"Minecraft"
],
"target_entities": [
"grass",
"player"
],
"strength": "moderate"
},
{
"description": "Placing grass blocks with snow on top of them turns them into snowy grass blocks.",
"source_entities": [
"Minecraft"
],
"target_entities": [
"snow",
"grass"
],
"strength": "strong"
},
{
"description": "Removing the snow layer turns the block into a normal grass block.",
"source_entities": [
"Minecraft"
],
"target_entities": [
"snowy grass block",
"grass"
],
"strength": "strong"
},
{
"description": "Dirt path blocks can be created by using any type of shovel on the side or top of a grass block with air above it.",
"source_entities": [
"Minecraft",
"grass"
],
"target_entities": [
"dirt path",
"shovel"
],
"strength": "strong"
},
{
"description": "The shovel loses 1 durability for each dirt path block created.",
"source_entities": [
"Minecraft",
"shovel"
],
"target_entities": [
"dirt path",
"shovel"
],
"strength": "moderate"
},
{
"description": "Death grass block dies and changes to dirt a random time (when a random tick lands on the block)",
"source_entities": [
"Minecraft"
],
"target_entities": [
"death grass block",
"dirt"
],
"strength": "strong"
},
{
"description": "Grass can be used to create dirt paths",
"source_entities": [
"Minecraft"
],
"target_entities": [
"grass",
"dirt path"
],
"strength": "strong"
}
]
}