Skip to content

Commit

Permalink
notes
Browse files Browse the repository at this point in the history
  • Loading branch information
mike dupont committed Feb 22, 2024
1 parent 7043e18 commit f42a8a9
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3071,3 +3071,27 @@
[submodule "2024/02/17/cmake"]
path = 2024/02/17/cmake
url = https://gitlab.kitware.com/cmake/cmake
[submodule "2024/02/20/math-comp"]
path = 2024/02/20/math-comp
url = https://github.com/math-comp/math-comp
[submodule "2024/02/20/coq-ai"]
path = 2024/02/20/coq-ai
url = https://github.com/romasoletskyi/coq-ai
[submodule "2024/02/20/coq_llm_interaction"]
path = 2024/02/20/coq_llm_interaction
url = https://github.com/K-dizzled/coq_llm_interaction
[submodule "2024/02/20/coq-llm-rl"]
path = 2024/02/20/coq-llm-rl
url = https://github.com/mtarunpr/coq-llm-rl
[submodule "2024/02/20/llm-verified-with-monte-carlo-tree-search"]
path = 2024/02/20/llm-verified-with-monte-carlo-tree-search
url = https://github.com/namin/llm-verified-with-monte-carlo-tree-search
[submodule "2024/02/21/emacs-head.nix"]
path = 2024/02/21/emacs-head.nix
url = https://github.com/HeinrichHartmann/emacs-head.nix
[submodule "2024/02/21/emacs-overlay"]
path = 2024/02/21/emacs-overlay
url = https://github.com/nix-community/emacs-overlay
[submodule "2024/02/21/llmvwmcts"]
path = 2024/02/21/llmvwmcts
url = https://huggingface.co/datasets/introspector/llmvwmcts
83 changes: 83 additions & 0 deletions 2024/02/17/notes.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
* ideas
** how to implement grammars in gbnf

given a menhir parser of gbnf,
which we have already built and tested in ocaml
and we can parse all the gbnf examples.

How to we make a gbnf of gbnf?

1. treesitter to gbnf
https://github.com/jonastemplestein/tree_sitter_grammar_to_gbnf/

2. menhir to treesitter to gbnf
https://github.com/Kerl13/tree-sitter-menhir has a treesitter menhir grammar

3. gbnf parser in menhir to treesitter to gbnf of gbnf parser


** another way of saying this is
menhir parser writen in treesitter lang
-> tree_sitter_grammar_to_gbnf
-> gbnf
menhir parser in gbnf
then llama cpp can now generate new menhir parsers
new menhir parsers can be converted to gbnf
then llama cpp can now generate new gbnf parsers
then llama cpp can now extend itself.

we can create ocaml wrappers for systems with effects.

(* Step 1: Create Menhir parser for gBNF *)
let gbnf_parser = MenhirParser.menhir_parse (...)

(* Step 2: Use Treesitter to convert AST to nested list *)
let ast = Treesitter.parse_with_grammar gbnf_grammar input_code

(* Step 3: Generate new gBNF string from AST *)
let new_gbnf = generate_gbnf_from_ast ast

let rec generate_gbnf (node : GbnfAst.node) =
match node with
| NonTerminal s -> s
| Terminal s -> s
| Rule (lhs, rhs) ->
let lhs_str = generate_gbnf lhs in
let rhs_str = String.concat " " (List.map generate_gbnf rhs) in
lhs_str ^ " -> " ^ rhs_str

let new_gbnf = generate_gbnf ast


(define-language gbnf
(pattern $production (prod_name arrow rhs) @production.node)
(pattern arrow ->)
(pattern prod_name (identifier))
(pattern rhs (seq+ term))
(pattern term (nonterm | terminal))
(pattern nonterm (identifier))
(pattern terminal #"[a-zA-Z0-9_]+"))


3. Write a function that takes the syntax tree and generates a new gBNF string from it:
```python
def generate_gbnf(node):
if node.type == 'production':
lhs = node.children[0].text
rhs = ' '.join([generate_gbnf(child) for child in node.children[1].children])
return f'{lhs} -> {rhs}'
elif node.type == 'term':
if node.children[0].type == 'nonterm':
return node.children[0].text
else:
return node.children[0].text[1:-1] # strip quotes
else:
raise ValueError(f'Unsupported node type: {node.type}')

new_gbnf = generate_gbnf(tree.root_node)



*
now to test with the latest version of cmake
git submodule add https://gitlab.kitware.com/cmake/cmake
1 change: 1 addition & 0 deletions 2024/02/21/llmvwmcts
Submodule llmvwmcts added at 66afc9
4 changes: 4 additions & 0 deletions 2024/02/22/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


verbs:
bash ./verbs.sh
12 changes: 12 additions & 0 deletions 2024/02/22/verbs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DS=$(date -Iseconds)
mkdir -p data/
echo "extract a list of verbs from the following text:" > prompt_verbs.txt
cat notes.org >> prompt_verbs.txt
mkdir data
# --ollama -m "mixtral" -u "https://mixtral-agentartificial.ngrok.app" \
~/.opam/4.13.1/bin/simple.exe \
--ollama -m "mistral:instruct" -u "http://localhost:11434" \
-f prompt_verbs.txt \
-s "data/out_${DS}" \
-x ".txt" \
-n 10

0 comments on commit f42a8a9

Please sign in to comment.