Skip to content

Commit

Permalink
add some test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Apr 30, 2024
1 parent 27845ee commit fb5fb81
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
43 changes: 43 additions & 0 deletions controllers/jsctrl/samples/count-yellow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Label, setLogLevel } from "aici"

const colors = [
// "red",
// "green",
"blue",
// "violet",
// "white",
// "black",
]

function gencolors(k) {
let s = []

for (let i = 0; i < k; ++i) {
s.push(colors[Math.floor(Math.random() * colors.length)])
}

return s.join(", ")
}

async function countYellow() {
setLogLevel(10)
const q = `Does the color yellow appear in the following list of colors?`
await $`<|user|>\n${q}\n`
const l = new Label()
for (let i = 0; i < 100; ++i) {
const hasYellow = Math.random() < 0.5
const A = (10 + Math.random() * 100) | 0
const B = (10 + Math.random() * 130) | 0
const text = gencolors(A) + (hasYellow ? ", yellow, " : ", blue, ") + gencolors(B)
await l.fixedAfter(`${text}<|end|>\n<|assistant|>`)
const r = await gen({ maxTokens: 10, regex: /(Yes|No)/ })
console.log(q)
console.log(text)
console.log(hasYellow ? "Yes" : "No", r)
assert(r === "Yes" || r === "No")
assert(r === (hasYellow ? "Yes" : "No"))
await $`\n`
}
}

start(countYellow)
33 changes: 33 additions & 0 deletions controllers/jsctrl/samples/mapping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Label, getTokens, setLogLevel } from "aici"

function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}

async function countYellow() {
setLogLevel(0)
const q = `Tell me the value of x42?`
await $`<|user|>\n${q}\n`
const l = new Label()
let numok = 0
for (let i = 0; i < 20; ++i) {
let text = ""
let x42 = randomInt(10, 99)
for (let i = 10; i < 300; ++i) {
text += `The value of x${i} is ${i == 42 ? x42 : randomInt(10, 99)}.\n`
}
await l.fixedAfter(`${text}\nTell me x42.<|end|>\n<|assistant|>The value of x42 is `)
const r = await gen({ maxTokens: 10, regex: /\d\d/ })
// console.log(q)
// console.log(text)
console.log(getTokens().length, x42, r, r === x42.toString())
if (r === x42.toString()) {
numok++
}
// assert(r === x42.toString())
await $`\n`
}
console.log("numok", numok)
}

start(countYellow)
2 changes: 1 addition & 1 deletion py/vllm
2 changes: 2 additions & 0 deletions scripts/vllm-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -x

if [ -z "$FOLDER" ]; then
MODEL_ARGS="--model microsoft/Orca-2-13b --revision refs/pr/22 --aici-tokenizer orca"
#MODEL_ARGS="--model microsoft/Phi-3-mini-128k-instruct --trust-remote-code"
#MODEL_ARGS="--model microsoft/Phi-3-mini-4k-instruct --trust-remote-code"
else
MODEL_ARGS="--model ./$FOLDER --aici-tokenizer ./$FOLDER/tokenizer.json --tokenizer ./$FOLDER"
fi
Expand Down

0 comments on commit fb5fb81

Please sign in to comment.