Update README (#7)

Update the description of the package.
This commit is contained in:
Eugene Yurtsev
2023-05-11 09:38:50 -04:00
committed by GitHub
parent 5fb5948184
commit 60090d8017
2 changed files with 71 additions and 36 deletions
+35 -17
View File
@@ -2,25 +2,42 @@
# Kork ![alt The Parrot](assets/parrot.png)
`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/chains.html) that can write and execute code safely.
`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/chains.html) that helps build natural language APIs powered by LLMs.
`Kork` **cannot** write *arbitrary* code. If that's what you need, save yourself some time and use [docker](https://www.docker.com/) and a real programming language.
## Features
`Kork` does not aim implement a fully functional programming language, but to make it
easier to get an LLM to code that is *safe* and *useful* for a *constrained* problem
domain.
1. Assemble a natural language API from a set of python functions.
2. Generate a prompt to help the LLM write a **correct** program.
3. Execute the program generated by the LLM **safely**.
4. Program generation takes a single LLM call, as opposed to agents that use a call per action taken.
A calculator powered by natural language is one example of a constrained problem domain.
## How
The main feature of the `Kork` programming language and interpreter is that it does not have any features. To do useful things with `Kork` a user specifies *foreign functions* that can be called from the `Kork` interpreter by the chain. The chain uses an LLM to translate a user query into a `Kork` program, which is then executed by a `Kork` interpreter.
The chain takes a user query, translates it into a program, and executes it using the `Kork` interpreter.
## Safety
The interpreter is used to run code written in the `Kork` programming language.
Nothing is bulletproof when humans are involved.
The language is limited by design to variable declarations, function invocations and arithmetic operations.
* Don't do silly things like exposing `eval` as a foreign function.
* If a foreign function allocates memory, the LLM could ask for more memory than is available crashing the process.
* Think carefully about whether the LLM could behave maliciously before trusting its output.
This limitation allows controlling the kind of programs the LLMs can generate, making the output of the LLM more predictable and safer to execute in a production setting. (An agent with access to "constrained" tools has similar benefits, but requires a call per action taken.)
`Kork` adds a few additional tricks (e.g., retriever interfaces for examples and foreign functions) to help guide the LLM to generate a **correct** program.
## What?
*No loops, no conditionals, no file access, no network access, no arbitrary code execution. WHAT?!*
The ability to invoke custom functions goes a long way in terms of the kinds of programs that can be written! (You can always add a `write_to_file` function!)
## Limitations
- `Kork` **cannot write arbitrary** code. If that's what you need, save yourself some time and use [docker](https://www.docker.com/) and a real programming language.
- The `Kork` chain is **not** an Agent, so it cannot inspect intermediate steps, instead it generates a pre-defined set of function calls that need to be executed. (But remember that function calls can involve calls to an agent!)
- The `Kork` language and interpreter are limited to *function invocation*, *variable declaration* and
*basic arithmetic* (no function declaration, loops etc.)
- Only supporting `int`, `float`, `str`, `type(None)`, `bool` types. No support for `lists` or `object` types.
- Very limited type annotations.
## Quality
@@ -35,12 +52,13 @@ it's programming in a specific language (e.g., typescript or python) and assume
that it can use language features that are not supported by `Kork` or to import
libraries that are not available.
## Limitations
## Safety
- The `Kork` language and interpreter are limited to *function invocation*, *variable declaration* and
*basic arithmetic* (no function declaration, loops etc.)
- Only supporting `int`, `float`, `str`, `type(None)`, `bool` types. No support for `lists` or `object` types.
- Very limited type annotations.
Nothing is bulletproof when humans are involved.
* Don't do silly things like exposing `eval` as a foreign function.
* If a foreign function allocates memory, the LLM could ask for more memory than is available crashing the process.
* Think carefully before using the output of an LLM. If the LLM behaves maliciously, is it safe to use an LLM in the given context?
## Future Work
+36 -19
View File
@@ -1,24 +1,41 @@
# Introduction
# Introduction
`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/chains.html) that can write and execute code safely.
`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/chains.html) that helps build natural language APIs powered by LLMs.
`Kork` **cannot** write *arbitrary* code. If that's what you need, save yourself some time and use [docker](https://www.docker.com/) and a real programming language.
## Features
`Kork` does not aim implement a fully functional programming language, but to make it
easier to get an LLM to code that is *safe* and *useful* for a *constrained* problem
domain.
1. Assemble a natural language API from a set of python functions.
2. Generate a prompt to help the LLM write a **correct** program.
3. Execute the program generated by the LLM **safely**.
4. Program generation takes a single LLM call, as opposed to agents that use a call per action taken.
A calculator powered by natural language is one example of a constrained problem domain.
## How
The main feature of the `Kork` programming language and interpreter is that it does not have any features. To do useful things with `Kork` a user specifies *foreign functions* that can be called from the `Kork` interpreter by the chain. The chain uses an LLM to translate a user query into a `Kork` program, which is then executed by a `Kork` interpreter.
The chain takes a user query, translates it into a program, and executes it using the `Kork` interpreter.
## Safety
The interpreter is used to run code written in the `Kork` programming language.
Nothing is bulletproof when humans are involved.
The language is limited by design to variable declarations, function invocations and arithmetic operations.
* Don't do silly things like exposing `eval` as a foreign function.
* If a foreign function allocates memory, the LLM could ask for more memory than is available crashing the process.
* Think carefully about whether the LLM could behave maliciously before trusting its output.
This limitation allows controlling the kind of programs the LLMs can generate, making the output of the LLM more predictable and safer to execute in a production setting. (An agent with access to "constrained" tools has similar benefits, but requires a call per action taken.)
`Kork` adds a few additional tricks (e.g., retriever interfaces for examples and foreign functions) to help guide the LLM to generate a **correct** program.
## What?
*No loops, no conditionals, no file access, no network access, no arbitrary code execution. WHAT?!*
The ability to invoke custom functions goes a long way in terms of the kinds of programs that can be written! (You can always add a `write_to_file` function!)
## Limitations
- `Kork` **cannot write arbitrary** code. If that's what you need, save yourself some time and use [docker](https://www.docker.com/) and a real programming language.
- The `Kork` chain is **not** an Agent, so it cannot inspect intermediate steps, instead it generates a pre-defined set of function calls that need to be executed. (But remember that function calls can involve calls to an agent!)
- The `Kork` language and interpreter are limited to *function invocation*, *variable declaration* and
*basic arithmetic* (no function declaration, loops etc.)
- Only supporting `int`, `float`, `str`, `type(None)`, `bool` types. No support for `lists` or `object` types.
- Very limited type annotations.
## Quality
@@ -33,12 +50,13 @@ it's programming in a specific language (e.g., typescript or python) and assume
that it can use language features that are not supported by `Kork` or to import
libraries that are not available.
## Limitations
## Safety
- The `Kork` language and interpreter are limited to *function invocation*, *variable declaration* and
*basic arithmetic* (no function declaration, loops etc.)
- Only supporting `int`, `float`, `str`, `type(None)`, `bool` types. No support for `lists` or `object` types.
- Very limited type annotations.
Nothing is bulletproof when humans are involved.
* Don't do silly things like exposing `eval` as a foreign function.
* If a foreign function allocates memory, the LLM could ask for more memory than is available crashing the process.
* Think carefully before using the output of an LLM. If the LLM behaves maliciously, is it safe to use an LLM in the given context?
## Future Work
@@ -75,7 +93,6 @@ See [CONTRIBUTING.md](https://github.com/langchain-ai/kork/blob/main/CONTRIBUTIN
Fast to type and maybe sufficiently unique.
```{toctree}
:maxdepth: 2
:caption: Contents