Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
βCITATION.cff file
-
βcodemeta.json file
Found codemeta.json file -
β.zenodo.json file
-
βDOI references
-
βAcademic publication links
-
βCommitters with academic emails
-
βInstitutional organization owner
-
βJOSS paper metadata
-
βScientific vocabulary similarity
Low similarity (15.6%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
LLM(π½)
Basic Info
- Host: GitHub
- Owner: eyurtsev
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://eyurtsev.github.io/kor/
- Size: 3 MB
Statistics
- Stars: 1,688
- Watchers: 15
- Forks: 95
- Open Issues: 27
- Releases: 20
Topics
Metadata Files
README.md
[!WARNING] If you're using a chat model that supports a tool calling API, you should probably be using the chat models' tool calling API instead of Kor!
Kor is best suited for old style LLMs that did not have a chat interface and did not support tool calling.
Read the tool calling guide in LangChain for more details.
Please refer to the chat model integration table for a list of chat models that support native tool calling.
Kor
This is a half-baked prototype that "helps" you extract structured data from text using LLMs π§©.
Specify the schema of what should be extracted and provide some examples.
Kor will generate a prompt, send it to the specified LLM and parse out the output.
You might even get results back.
So yes β itβs just another wrapper on top of LLMs with its own flavor of abstractions. πΈ
See documentation.
Integrated with the LangChain framework π½π π¦π.
Kor vs. LangChain
There are 3 different approaches for extracting information using LLMs:
- prompt based/parsing
- function/tool calling
- JSON mode
Please see the LangChain extraction use case docs for an overview.
Kor has a pretty good implementation of the parsing approach. The approach works with all good-enough LLMs regardless of whether they support function/tool calling or JSON modes.
Extraction quality is principally driven by providing good reference examples and good schema documentation.
Please see guidelines here and here.
Version 1.0.0 Release
korcompatible with both pydantic v2 and v1.- pydantic v2 had significant breaking changes w/ respect to v1,
kormajor version bump was used as a precaution.
Main things to watch out for:
- Use a
defaultvalue for any Optional fields if using pydantic v2 for validation.
python
class MusicRequest(BaseModel):
song: Optional[List[str]] = Field(
default=None,
description="The song(s) that the user would like to be played."
)
Kor schema is typed checked using pydantic. Pydantic v2 is stricter, and may catch issues that were hiding in existing user code that was using the
korlibrary.Serialization has not yet been implemented with pydantic v2.
Kor style schema
```python from langchain.chatmodels import ChatOpenAI from kor import createextraction_chain, Object, Text
llm = ChatOpenAI( modelname="gpt-3.5-turbo", temperature=0, maxtokens=2000, modelkwargs = { 'frequencypenalty':0, 'presencepenalty':0, 'topp':1.0 } )
schema = Object(
id="player",
description=(
"User is controlling a music player to select songs, pause or start them or play"
" music by a particular artist."
),
attributes=[
Text(
id="song",
description="User wants to play this song",
examples=[],
many=True,
),
Text(
id="album",
description="User wants to play this album",
examples=[],
many=True,
),
Text(
id="artist",
description="Music by the given artist",
examples=[("Songs by paul simon", "paul simon")],
many=True,
),
Text(
id="action",
description="Action to take one of: play, stop, next, previous.",
examples=[
("Please stop the music", "stop"),
("play something", "play"),
("play a song", "play"),
("next song", "next"),
],
),
],
many=False,
)
chain = createextractionchain(llm, schema, encoderorencoder_class='json') chain.invoke("play songs by paul simon and led zeppelin and the doors")['data'] ```
python
{'player': {'artist': ['paul simon', 'led zeppelin', 'the doors']}}
Pydantic style schema
- See documentation here pydantic.
```python class Action(enum.Enum): play = "play" stop = "stop" previous = "previous" next_ = "next"
class MusicRequest(BaseModel):
song: Optional[List[str]] = Field(
default=None,
description="The song(s) that the user would like to be played."
)
album: Optional[List[str]] = Field(
default=None,
description="The album(s) that the user would like to be played."
)
artist: Optional[List[str]] = Field(
default=None,
description="The artist(s) whose music the user would like to hear.",
examples=[("Songs by paul simon", "paul simon")],
)
action: Optional[Action] = Field(
default=None,
description="The action that should be taken; one of play, stop, next, previous",
examples=[
("Please stop the music", "stop"),
("play something", "play"),
("play a song", "play"),
("next song", "next"),
],
)
schema, validator = frompydantic(MusicRequest)
chain = createextractionchain(
llm, schema, encoderorencoderclass="json", validator=validator
)
chain.invoke("stop the music now")["validated_data"]
```
python
MusicRequest(song=None, album=None, artist=None, action=<Action.stop: 'stop'>)
Compatibility
Kor is tested against python 3.8, 3.9, 3.10, 3.11.
Installation
sh
pip install kor
π‘ Ideas
Ideas of some things that could be done with Kor.
- Extract data from text that matches an extraction schema.
- Power an AI assistant with skills by precisely understanding a user request.
- Provide natural language access to an existing API.
π§ Prototype
Prototype! So the API is not expected to be stable!
β¨ What does Kor excel at? π
- Making mistakes! Plenty of them!
- Slow! It uses large prompts with examples, and works best with the larger slower LLMs.
- Crashing for long enough pieces of text! Context length window could become limiting when working with large forms or long text inputs.
The expectation is that as LLMs improve some of these issues will be mitigated.
Limitations
Kor has no limitations. (Just kidding.)
Take a look at the section above and at the compatibility section.
Got Ideas?
Open an issue, and let's discuss!
πΆ Why the name?
Fast to type and sufficiently unique.
Contributing
If you have any ideas or feature requests, please open an issue and share!
See CONTRIBUTING.md for more information.
Other packages
Probabilistically speaking this package is unlikely to work for your use case.
So here are some great alternatives:
Owner
- Name: Eugene Yurtsev
- Login: eyurtsev
- Kind: user
- Location: Boston
- Company: @langchain-ai
- Website: eyurtsev.github.io
- Twitter: veryboldbagel
- Repositories: 40
- Profile: https://github.com/eyurtsev
SWE | ML | Chief Data Kitten
GitHub Events
Total
- Issues event: 2
- Watch event: 72
- Delete event: 1
- Issue comment event: 5
- Push event: 1
- Pull request event: 6
- Fork event: 9
- Create event: 4
Last Year
- Issues event: 2
- Watch event: 72
- Delete event: 1
- Issue comment event: 5
- Push event: 1
- Pull request event: 6
- Fork event: 9
- Create event: 4
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Eugene Yurtsev | e****v@g****m | 214 |
| dependabot[bot] | 4****] | 5 |
| Boris Wilhelms | m****l@w****e | 3 |
| Vadym Barda | v****a@g****m | 1 |
| Tom Dyson | t****m@t****m | 1 |
| Stephen Witkowski | s****i@p****m | 1 |
| Seb0 | S****0 | 1 |
| Sachin Bhat | s****7@g****m | 1 |
| Rishabh Jain | r****8@g****m | 1 |
| Ikko Eltociear Ashimine | e****r@g****m | 1 |
| Harrison Chase | h****7@g****m | 1 |
| Chaim Turkel | c****l@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 81
- Total pull requests: 160
- Average time to close issues: about 2 months
- Average time to close pull requests: 14 days
- Total issue authors: 60
- Total pull request authors: 14
- Average comments per issue: 3.05
- Average comments per pull request: 0.46
- Merged pull requests: 119
- Bot issues: 0
- Bot pull requests: 33
Past Year
- Issues: 5
- Pull requests: 7
- Average time to close issues: about 7 hours
- Average time to close pull requests: 35 minutes
- Issue authors: 5
- Pull request authors: 2
- Average comments per issue: 1.8
- Average comments per pull request: 0.14
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 3
Top Authors
Issue Authors
- eyurtsev (7)
- hitsense (3)
- MauroLondon (2)
- Feya (2)
- nans-here (2)
- shatealaboxiaowang (2)
- mann2107 (2)
- smwitkowski (2)
- Sachin-Bhat (2)
- BorisWilhelms (2)
- DavideBFerri (2)
- oliverbj (2)
- rlancemartin (1)
- ihorizons2022 (1)
- NicoSzela (1)
Pull Request Authors
- eyurtsev (124)
- dependabot[bot] (51)
- sshussain270 (2)
- chaimt (2)
- PrasannaIITM (2)
- BorisWilhelms (2)
- Sachin-Bhat (2)
- smwitkowski (1)
- nfcampos (1)
- tomdyson (1)
- eltociear (1)
- Seb0 (1)
- rishabhjain1198 (1)
- Zakharyan9889 (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 39,691 last-month
- Total docker downloads: 4,564
-
Total dependent packages: 10
(may contain duplicates) -
Total dependent repositories: 53
(may contain duplicates) - Total versions: 36
- Total maintainers: 1
pypi.org: fcsparser
A python package for reading raw fcs files
- Homepage: https://www.github.com/eyurtsev/kor
- Documentation: https://fcsparser.readthedocs.io/
- License: MIT
-
Latest release: 0.2.8
published over 2 years ago
Rankings
Maintainers (1)
pypi.org: kor
Extract information with LLMs from text
- Homepage: https://www.github.com/eyurtsev/kor
- Documentation: https://kor.readthedocs.io/
- License: MIT
-
Latest release: 3.0.0
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- peaceiris/actions-gh-pages v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- 171 dependencies
- langchain >=0.0.110
- markdownify ^0.11.6
- openai ^0.27
- pandas ^1.5.3
- python ^3.8.1