coyotte508 HF staff commited on
Commit
9d01b14
1 Parent(s): 690cd19

🩹 Only trim end of string & add "Assistant:" to stop words (#180)

Browse files
.env CHANGED
@@ -64,7 +64,7 @@ MODELS=`[
64
  "repetition_penalty": 1.2,
65
  "truncate": 8000,
66
  "max_new_tokens": 2000,
67
- "stop": ["Human:", "-----"]
68
  }
69
  }
70
  ]`
 
64
  "repetition_penalty": 1.2,
65
  "truncate": 8000,
66
  "max_new_tokens": 2000,
67
+ "stop": ["Human:", "-----", "Assistant:"]
68
  }
69
  }
70
  ]`
src/routes/admin/export/+server.ts CHANGED
@@ -7,7 +7,7 @@ import { collections } from "$lib/server/database.js";
7
  import type { Message } from "$lib/types/Message.js";
8
  import { error } from "@sveltejs/kit";
9
  import { pathToFileURL } from "node:url";
10
- import { unlink, writeFile } from "node:fs/promises";
11
  import { uploadFile } from "@huggingface/hub";
12
  import parquet from "parquetjs";
13
  import { z } from "zod";
 
7
  import type { Message } from "$lib/types/Message.js";
8
  import { error } from "@sveltejs/kit";
9
  import { pathToFileURL } from "node:url";
10
+ import { unlink } from "node:fs/promises";
11
  import { uploadFile } from "@huggingface/hub";
12
  import parquet from "parquetjs";
13
  import { z } from "zod";
src/routes/conversation/[id]/+server.ts CHANGED
@@ -110,11 +110,11 @@ export async function POST({ request, fetch, locals, params }) {
110
  generated_text = trimSuffix(
111
  trimPrefix(generated_text, "<|startoftext|>"),
112
  PUBLIC_SEP_TOKEN
113
- ).trim();
114
 
115
  for (const stop of [...(modelInfo?.parameters?.stop ?? []), "<|endoftext|>"]) {
116
  if (generated_text.endsWith(stop)) {
117
- generated_text = generated_text.slice(0, -stop.length).trim();
118
  }
119
  }
120
 
 
110
  generated_text = trimSuffix(
111
  trimPrefix(generated_text, "<|startoftext|>"),
112
  PUBLIC_SEP_TOKEN
113
+ ).trimEnd();
114
 
115
  for (const stop of [...(modelInfo?.parameters?.stop ?? []), "<|endoftext|>"]) {
116
  if (generated_text.endsWith(stop)) {
117
+ generated_text = generated_text.slice(0, -stop.length).trimEnd();
118
  }
119
  }
120