Skip to content

Commit

Permalink
Skip conversion and quantizing if they have already been done
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswestin committed Mar 13, 2023
1 parent 83093ac commit f65e03e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Dalai {

for(let file of files) {
if (fs.existsSync(path.resolve(resolvedPath, file))) {
console.log(`Skip file, it already exists: ${file}`)
console.log(`Skip file download, it already exists: ${file}`)
continue;
}

Expand All @@ -62,8 +62,8 @@ class Dalai {

const files2 = ["tokenizer_checklist.chk", "tokenizer.model"]
for(let file of files2) {
if (path.resolve(this.home, "models", file)) {
console.log(`Skip file, it already exists: ${file}`)
if (fs.existsSync(path.resolve(this.home, "models", file))) {
console.log(`Skip file download, it already exists: ${file}`)
continue;
}
const task = `downloading ${file}`
Expand Down Expand Up @@ -93,7 +93,12 @@ class Dalai {
await this.exec("make", this.home)
for(let model of models) {
await this.download(model)
await this.exec(`python3 convert-pth-to-ggml.py models/${model}/ 1`, this.home)
const outputFile = path.resolve(this.home, 'models', model, 'ggml-model-f16.bin')
if (fs.existsSync(outputFile)) {
console.log(`Skip conversion, file already exists: ${outputFile}`)
} else {
await this.exec(`python3 convert-pth-to-ggml.py models/${model}/ 1`, this.home)
}
await this.quantize(model)
}
}
Expand Down Expand Up @@ -198,7 +203,13 @@ class Dalai {
}
for(let i=0; i<num[model]; i++) {
const suffix = (i === 0 ? "" : `.${i}`)
await this.exec(`./quantize ./models/${model}/ggml-model-f16.bin${suffix} ./models/${model}/ggml-model-q4_0.bin${suffix} 2`, this.home)
const outputFile1 = `./models/${model}/ggml-model-f16.bin${suffix}`
const outputFile2 = `./models/${model}/ggml-model-q4_0.bin${suffix}`
if (fs.existsSync(path.resolve(this.home, outputFile1)) && fs.existsSync(path.resolve(this.home, outputFile2))) {
console.log(`Skip quantization, files already exists: ${outputFile1} and ${outputFile2}}`)
continue
}
await this.exec(`./quantize ${outputFile1} ${outputFile2} 2`, this.home)
}
}
progress(task, percent) {
Expand Down

0 comments on commit f65e03e

Please sign in to comment.