-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mike dupont
committed
Feb 17, 2024
1 parent
ea7f6c9
commit 2350d7d
Showing
12 changed files
with
191 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
GRAMMAR=~/experiments/gbnf_parser/grammars/ebnf.ebnf | ||
GRAMMAR_C=$(cat $GRAMMAR) | ||
|
||
GRAMMAR2=~/experiments/gbnf_parser/lib/sentenceParser.mly | ||
GRAMMAR2_C=$( cat $GRAMMAR2 ) | ||
|
||
DATA=$(cat notes.org) | ||
DS=$(date -Iseconds) | ||
PROMPT_NAME="prompt_grammar2_${DS}.txt" | ||
|
||
echo "Consider the following grammar between BEGINSRC and ENDSRC. BEGINSRC ${GRAMMAR2_C} ENDSRC . Please rewrite it to be more beautiful. We are going to use the following TARGET: BEGINTARGET ${GRAMMAR_C} ENDTARGET as our target grammar format. Please rewrite SRC into TARGET. " > $PROMPT_NAME | ||
|
||
dune exec bin/simple_grammar.exe -- \ | ||
--llamacpp \ | ||
-u "http://localhost:8080" \ | ||
-s "grammar_1_${DS}" \ | ||
-g $GRAMMAR \ | ||
-p $PROMPT_NAME \ | ||
-x ".txt" \ | ||
-n 6 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
GRAMMAR=~/experiments/gbnf_parser/grammars/ebnf.ebnf | ||
DS=$(date -Iseconds) | ||
PROMPT_NAME=prompt_grammar2.txt | ||
|
||
dune exec bin/simple_grammar.exe -- \ | ||
--llamacpp \ | ||
-u "http://localhost:8080" \ | ||
-s "grammar_1_${DS}" \ | ||
-g $GRAMMAR \ | ||
-p $PROMPT_NAME \ | ||
-x ".txt" \ | ||
-n 6 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
GRAMMAR=~/experiments/gbnf_parser/grammars/ebnf.ebnf | ||
DS=$(date -Iseconds) | ||
PROMPT_NAME=prompt_grammar2c.txt | ||
|
||
dune exec bin/simple_grammar.exe -- \ | ||
--llamacpp \ | ||
-u "http://localhost:8080" \ | ||
-s "grammar_1_${DS}" \ | ||
-g $GRAMMAR \ | ||
-p $PROMPT_NAME \ | ||
-x ".txt" \ | ||
-n 6 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
GRAMMAR=~/experiments/gbnf_parser/grammars/ebnf.ebnf | ||
DS=$(date -Iseconds) | ||
PROMPT_NAME=prompt_grammar2c.txt | ||
PROMPT_C="$(cat $PROMPT_NAME)" | ||
dune exec bin/simple.exe -- \ | ||
--llamacpp \ | ||
-u "http://localhost:8080" \ | ||
-p "${PROMPT_C}" \ | ||
-x ".txt" \ | ||
-n 6 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Consider the following grammar between BEGINSRC and ENDSRC. BEGINSRC | ||
%{ | ||
open Syntax | ||
%} | ||
%token <int> Tchar | ||
%token DASH "-" | ||
%token CARET "^" | ||
%token | ||
BAR "|" | ||
EOF "" | ||
LPAREN "(" | ||
RPAREN ")" | ||
QUESTION "?" | ||
STAR "*" | ||
PLUS "+" | ||
NEWLINE | ||
|
||
%token <string Positions.located> | ||
LID "lident" | ||
REGEX "regex" | ||
QID "\"alias\"" | ||
|
||
%token | ||
COLONCOLONEQUAL "::=" | ||
|
||
%start <Syntax.partial_grammar> grammar | ||
%type <Syntax.myfactor> factor | ||
%type <Syntax.myfactor> alternation | ||
%type <Syntax.myfactor> modifier | ||
%type <Syntax.myfactor> complexterms | ||
%type <Syntax.myfactor> term | ||
%type <Syntax.myfactor> fstar | ||
%type <Syntax.myfactor> sterm | ||
%type <Syntax.myfactor> char_class | ||
%type <string Positions.located> lid | ||
%type <string Positions.located> qid | ||
%type <Syntax.myfactor> termfactor | ||
|
||
TRUNCATEDPART1 | ||
ENDSRC . | ||
|
||
Please rewrite it to be more beautiful. We are going to use the following TARGET: BEGINTARGET letter ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | ||
|
||
digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | ||
# removed " | "\f" | "\b" | ||
symbol ::= "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">" | "'" | "=" | "|" | "." | "," | ";" | "-" | "+" | "*" | "?" | "\n" | "\t" | "\r" | ||
|
||
character ::= letter | digit | symbol | "_" | " " | ||
identifier ::= letter ( letter | digit | "_" ) | ||
|
||
#| "\f" | "\b" | ||
S ::= ( " " | "\n" | "\t" | "\r" ) | ||
|
||
terminal ::= "'" character "'" ( character "'" ) "'" | ||
|
||
terminator ::= (";" | ".") | ||
|
||
term ::= "(" S rhs S ")" | "[" S rhs S "]" | "{" S rhs S "}" | terminal | identifier | ||
|
||
factor ::= term S "?" | term S "*" | term S "+" | term S "-" S term | term S | ||
|
||
concatenation ::= ( S factor S "," ? ) + | ||
alternation ::= ( S concatenation S "|" ? ) + | ||
|
||
rhs ::= alternation | ||
lhs ::= identifier | ||
|
||
rule ::= lhs S "=" S rhs S terminator | ||
|
||
root ::= ( S rule S ) * ENDTARGET as our target grammar format. Please rewrite SRC into TARGET. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Please rewrite the following to be more beautiful. | ||
please answer only in the following grammar. | ||
|
||
BEGIN | ||
terminal ::= "'" character "'" ( character "'" ) "'" | ||
terminator ::= (";" | ".") | ||
term ::= "(" S rhs S ")" | "[" S rhs S "]" | "{" S rhs S "}" | terminal | identifier | ||
factor ::= term S "?" | term S "*" | term S "+" | term S "-" S term | term S | ||
concatenation ::= ( S factor S "," ? ) + | ||
alternation ::= ( S concatenation S "|" ? ) + | ||
rhs ::= alternation | ||
lhs ::= identifier | ||
rule ::= lhs S "=" S rhs S terminator | ||
root ::= ( S rule S ) * | ||
END |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
GRAMMAR=$( cat ~/experiments/gbnf_parser/grammars/ebnf.ebnf) | ||
echo "consider a consecutive series of types to describe the universe and universe of universes, what is your ordering?" > prompt.txt | ||
|
||
dune exec ./bin/simple_grammar.exe -- --llamacpp -s test4 -u "http://localhost:8080" -n 4 -g "$GRAMMAR" -p prompt.txt |