ai-compare-candidates 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.editorconfig +0 -0
  2. package/.vscode/settings.json +0 -0
  3. package/.yarnrc.yml +0 -0
  4. package/LICENSE +0 -0
  5. package/README.md +14 -2
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +0 -0
  9. package/dist/index.d.cts.map +1 -1
  10. package/dist/index.d.mts +0 -0
  11. package/dist/index.d.mts.map +1 -1
  12. package/dist/index.mjs +1 -1
  13. package/dist/index.mjs.map +1 -1
  14. package/example/.editorconfig +0 -0
  15. package/example/.vscode/extensions.json +0 -0
  16. package/example/.vscode/settings.json +0 -0
  17. package/example/README.md +0 -0
  18. package/example/index.html +0 -0
  19. package/example/package.json +1 -1
  20. package/example/postcss.config.js +0 -0
  21. package/example/public/favicon.ico +0 -0
  22. package/example/public/icons/favicon-128x128.png +0 -0
  23. package/example/public/icons/favicon-16x16.png +0 -0
  24. package/example/public/icons/favicon-32x32.png +0 -0
  25. package/example/public/icons/favicon-96x96.png +0 -0
  26. package/example/quasar.config.ts +0 -0
  27. package/example/src/App.vue +0 -0
  28. package/example/src/boot/electronHuggingFaceFix.ts +0 -0
  29. package/example/src/boot/icons.ts +0 -0
  30. package/example/src/css/app.scss +0 -0
  31. package/example/src/css/quasar.variables.scss +0 -0
  32. package/example/src/env.d.ts +0 -0
  33. package/example/src/layouts/app.vue +0 -0
  34. package/example/src/router/index.ts +0 -0
  35. package/example/src/router/routes.ts +0 -0
  36. package/example/src/stores/index.ts +0 -0
  37. package/example/src/stores/store.ts +0 -0
  38. package/example/tsconfig.json +0 -0
  39. package/package.json +1 -1
  40. package/src/index.ts +4 -0
  41. package/tsconfig.json +0 -0
  42. package/tsconfig.node.json +0 -0
  43. package/tsconfig.tsbuildinfo +1 -1
  44. package/tsdown.config.ts +0 -0
package/.editorconfig CHANGED
File without changes
File without changes
package/.yarnrc.yml CHANGED
File without changes
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -44,6 +44,7 @@ AICompareCandidates.compareCandidates<Candidate>({
44
44
  candidates,
45
45
  problemDescription='',
46
46
  generateSearchAreasInstruction=this.defaultGenerateSearchAreasInstruction.bind(this),
47
+ parseSearchAreasResponse=this.defaultParseSearchAreasResponse.bind(this),
47
48
  convertCandidateToDocument=this.defaultConvertCandidateToDocument.bind(this),
48
49
  candidatesForInitialSelection=2,
49
50
  candidatesForFinalSelection=1,
@@ -51,7 +52,10 @@ AICompareCandidates.compareCandidates<Candidate>({
51
52
  extractIdentifiersFromRationale=this.defaultExtractIdentifiersFromRationale.bind(this),
52
53
  extractIdentifierFromCandidateDocument=this.defaultExtractIdentifierFromCandidateDocument.bind(this),
53
54
  candidateIdentifierField=undefined,
54
- getSummarisableSubstringIndices
55
+ findCandidateFromIdentifier=this.defaultFindCandidateFromIdentifier.bind(this),
56
+ getSummarisableSubstringIndices,
57
+ generatePromptTemplate=this.defaultGeneratePromptTemplate.bind(this),
58
+ skipRationale=false
55
59
  }:AICompareCandidates.CompareArguments<Candidate>=<AICompareCandidates.CompareArguments<Candidate>>{}):Promise<AICompareCandidates.CompareCandidatesReturn<Candidate>|void>
56
60
  ```
57
61
  candidates: Candidate objects as you define them
@@ -60,6 +64,8 @@ problemDescription: The prompt for description of the problem, i.e. how you woul
60
64
 
61
65
  generateSearchAreasInstruction: A function for generating the instruction for determining the relevant subject areas to use to search the vector database.
62
66
 
67
+ parseSearchAreasResponse: A function to parse the search areas response returned by the generator.
68
+
63
69
  convertCandidateToDocument: A function to convert a candidate object to a candidate document, i.e. a string, which can be embedded in the vector database.
64
70
 
65
71
  candidatesForInitialSelection: The number of candidates which should be returned by the initial vector database search.
@@ -74,4 +80,10 @@ extractIdentifierFromCandidateDocument: A function for extracting the correct ca
74
80
 
75
81
  candidateIdentifierField: The field in the candidate object which is used to identify it, e.g. name or ID number.
76
82
 
77
- getSummarisableSubstringIndices: A function for identifying the substring indices of a candidate document string which can be summarised by the summarisation model.
83
+ findCandidateFromIdentifier: A function for finding a candidate object from a provided identifier field.
84
+
85
+ getSummarisableSubstringIndices: A function for identifying the substring indices of a candidate document string which can be summarised by the summarisation model.
86
+
87
+ generatePromptTemplate: A function for generating the template for the prompt to the generator.
88
+
89
+ skipRationale: Whether to skip rationale generation.
package/dist/index.cjs CHANGED
@@ -22,5 +22,5 @@ Format exactly:
22
22
  #2. ...`}regexIndexOf(e,t,n){let r=e.slice(n).search(t);return r<0?r:r+n}defaultExtractIdentifierFromCandidateDocument({candidateDocument:e,candidateIdentifierField:t}={}){this.DEBUG&&console.log(e,t);let n=d.default.startCase(t),r=e.indexOf(n);if(r<0&&(r=e.toLowerCase().indexOf(n.toLowerCase())),this.DEBUG&&console.log(r),r>=0&&(r+=n.length),r<0&&(r=e.toLowerCase().indexOf(t.toLowerCase()),r>=0&&(r+=t.length)),this.DEBUG)console.log(r);else return``;if(r=e.indexOf(`:`,r),this.DEBUG&&console.log(r),r<0&&(r=this.regexIndexOf(e,/\s+/,r)),this.DEBUG&&console.log(r),r<0)return``;let i=e.indexOf(`
23
23
  `,r);return i<0&&(i=e.length),this.DEBUG&&console.log(i),e.substring(r,i).trim()}defaultExtractIdentifiersFromRationale(e){let t=/^\s*#\s*\d+\s*\.?\s*"([^"]+)"/gm,n=[];for(let r;Array.isArray(r=t.exec(e));)r[1]&&n.push(r[1]);return n}defaultFindCandidateFromIdentifier({identifier:e,candidateIdentifierField:t,candidates:n}={}){let r=n.find(n=>String(n[t]).toLowerCase()===e.toLowerCase());if(r||(r=n.find(n=>String(n[t]).toLowerCase().includes(e.toLowerCase())),r)||(r=n.find(n=>e.toLowerCase().includes(String(n[t]).toLowerCase())),r))return r;let i=e.split(/\s+/g),a=n.map(e=>({identifierWordIndices:i.map(n=>String(e[t]).indexOf(n)),candidate:e})).sort((e,t)=>{let n=d.default.sumBy(e.identifierWordIndices,e=>e<0?0:1),r=d.default.sumBy(t.identifierWordIndices,e=>e<0?0:1);if(n!==r)return r-n;if(n===0&&r===0)return 0;n=0,r=0;for(let t=0;t<e.identifierWordIndices.length-1;++t)for(let r=t+1;r<e.identifierWordIndices.length;++r)e.identifierWordIndices[t]<0||e.identifierWordIndices[r]<0||e.identifierWordIndices[t]<e.identifierWordIndices[r]&&++n;for(let e=0;e<t.identifierWordIndices.length-1;++e)for(let n=e+1;n<t.identifierWordIndices.length;++n)t.identifierWordIndices[e]<0||t.identifierWordIndices[n]<0||t.identifierWordIndices[e]<t.identifierWordIndices[n]&&++r;return r-n});return a[0].identifierWordIndices.some(e=>e>=0)?a[0].candidate:null}defaultParseSearchAreasResponse(e){let t=String(e).indexOf(`### Response:`);return t>=0?t+=13:t=0,String(e).substring(t).trim()}async compareCandidates({candidates:e,problemDescription:t=``,generateSearchAreasInstruction:n=this.defaultGenerateSearchAreasInstruction.bind(this),parseSearchAreasResponse:r=this.defaultParseSearchAreasResponse.bind(this),convertCandidateToDocument:i=this.defaultConvertCandidateToDocument.bind(this),candidatesForInitialSelection:a=2,candidatesForFinalSelection:o=1,generateRankingInstruction:s=this.defaultGenerateRankingInstruction.bind(this),extractIdentifiersFromRationale:c=this.defaultExtractIdentifiersFromRationale.bind(this),extractIdentifierFromCandidateDocument:u=this.defaultExtractIdentifierFromCandidateDocument.bind(this),candidateIdentifierField:f=void 0,findCandidateFromIdentifier:p=this.defaultFindCandidateFromIdentifier.bind(this),getSummarisableSubstringIndices:m,generatePromptTemplate:h=this.defaultGeneratePromptTemplate.bind(this),skipRationale:g=!1}={}){if(!Array.isArray(e)||e.length<=0)throw Error(`No candidates provided`);if(a=d.default.toSafeInteger(a),a<=0||(o=d.default.toSafeInteger(o),o<=0))throw Error(`Candidates for initial selection must be a positive integer bigger than 0`);if(a<o)throw Error(`Candidates for initial selection must be equal or more than candidates for final selection`);if(a>e.length)throw Error(`There are `+a+`candidates for initial selection which is more than the total number of candidates of `+e.length);if(o>e.length)throw Error(`There are `+o+`candidates for initial selection which is more than the total number of candidates of `+e.length);if(!f&&(f=Object.keys(e[0])[0],!f))throw Error(`No candidate identifier field`);let _=``,v=[];if(await this.checkEmbedderLoaded(),!this.embedder)return;let y=e.map((e,t)=>i({candidate:e,index:t})),b=await l.MemoryVectorStore.fromTexts(d.default.cloneDeep(y),y.map((e,t)=>t),this),x=h(n(t));if(this.DEBUG&&console.log(`Formatted search areas prompt: `+x),await this.checkTokeniserLoaded(),!this.tokeniser)return;if(this.tokeniser.encode(x).length>this.tokeniser.model_max_length)throw Error(`Search areas instruction prompt is too long for the tokeniser model`);if(await this.checkGeneratorLoaded(),!this.generator)return;let S=this.tokeniser.pad_token_id??this.tokeniser.sep_token_id??0,C=this.tokeniser.sep_token_id??2,w=await this.generator(x,{max_new_tokens:this.generateSearchAreasMaxNewTokens,temperature:this.generateSearchAreasTemperature,repetition_penalty:this.generateSearchAreasRepetitionPenalty,pad_token_id:S,eos_token_id:C}),T=Array.isArray(w?.[0])?w?.[0]?.[0]:w?.[0];if(!T.generated_text)throw Error(`No generated text for search areas`);this.DEBUG&&console.log(`Generated search areas response: `+T.generated_text);let E=r(Array.isArray(T.generated_text)?T.generated_text.join(`
24
24
 
25
- `):String(T.generated_text));this.DEBUG&&console.log(`Vector search query: `+E);let D=await b.similaritySearch(E,a);this.DEBUG&&console.log(`Vector search results: `,D);let O=[];if(D.some(e=>e.pageContent.trim().split(/\s+/).length>this.targetSummarisedStringTokenCount)){if(await this.checkSummariserLoaded(),!this.summariser)return;O=(await Promise.allSettled(D.map(async e=>{if(!e.pageContent||typeof e.pageContent!=`string`)return``;if(e.pageContent.trim().split(/\s+/).length<=this.targetSummarisedStringTokenCount)return e.pageContent;let t={start:0,end:e.pageContent.length};m&&Object.assign(t,m(e.pageContent)),t.start=d.default.clamp(d.default.toSafeInteger(t.start),0,e.pageContent.length),t.end=d.default.clamp(d.default.toSafeInteger(t.end),0,e.pageContent.length);let n=e.pageContent.substring(t.start,t.end),r=e.pageContent.substring(0,t.start),i=e.pageContent.substring(t.end),a=r.split(/s+/).length+i.split(/s+/).length,o=Math.max(1,this.targetSummarisedStringTokenCount-a),s=await this.summariser?.(n,{max_length:o}),c=r+((Array.isArray(s?.[0])?s?.[0]?.[0]:s?.[0])?.summary_text??``).split(/s+/).slice(o).join(` `)+i;return this.DEBUG&&console.log(`Summarised candidate: `+c),c}))).filter(e=>e.status===`fulfilled`&&e.value).map(e=>e.value)}else O=D.map(e=>e.pageContent);if(!g){let e=h(s({problemDescription:t,summaries:O,candidatesForFinalSelection:o,candidateIdentifierField:String(f)}));if(this.DEBUG&&console.log(`Formatted ranking prompt: `+e),this.tokeniser.encode(e).length>this.tokeniser.model_max_length)throw Error(`Ranking instruction prompt is too long for the tokeniser model`);try{let t=await this.generator(e,{max_new_tokens:this.rankingMaxNewTokens,temperature:this.rankingTemperature,repetition_penalty:this.rankingRepetitionPenalty,pad_token_id:S,eos_token_id:C});_=(Array.isArray(t?.[0])?t?.[0]?.[0]:t[0]).generated_text.toString().trim().replace(/(\*\*)|(<\/?s>)|(\[.*?\])\s*/g,``),this.DEBUG&&console.log(`Generated rationale: `+_);let n=_.indexOf(`### Response:`);n>=0?n+=13:n=0,_=_.substring(n)}catch(e){console.log(e),_=``}}if(_){let t=c(_);this.DEBUG&&console.log(`Extracted identifiers from rationale: `+t),t.length>o&&(t=t.slice(0,o)),v=d.default.compact(t.map(t=>p({identifier:t,candidateIdentifierField:f,candidates:e})))}if(!Array.isArray(v)||v.length<o){Array.isArray(v)||(v=[]);let t=d.default.compact(D.map(t=>{let n=u({candidateDocument:t.pageContent,candidateIdentifierField:String(f)});return this.DEBUG&&console.log(`Extracted identifier from candidate document: `+n),p({identifier:n,candidateIdentifierField:f,candidates:e})}));v.splice(v.length,0,...t),v=d.default.uniq(v).slice(0,o-v.length)}return this.DEBUG&&console.log(`Selected candidates`,v),{rationale:_,selectedCandidates:v}}};(function(e){})(p||={});var m=p;Object.defineProperty(exports,`AICompareCandidates`,{enumerable:!0,get:function(){return p}}),exports.default=m;
25
+ `):String(T.generated_text));this.DEBUG&&console.log(`Vector search query: `+E);let D=await b.similaritySearch(E,a);this.DEBUG&&console.log(`Vector search results: `,D);let O=[];if(D.some(e=>e.pageContent.trim().split(/\s+/).length>this.targetSummarisedStringTokenCount)){if(await this.checkSummariserLoaded(),!this.summariser)return;O=(await Promise.allSettled(D.map(async e=>{if(!e.pageContent||typeof e.pageContent!=`string`)return``;if(e.pageContent.trim().split(/\s+/).length<=this.targetSummarisedStringTokenCount)return e.pageContent;let t={start:0,end:e.pageContent.length};m&&Object.assign(t,m(e.pageContent)),t.start=d.default.clamp(d.default.toSafeInteger(t.start),0,e.pageContent.length),t.end=d.default.clamp(d.default.toSafeInteger(t.end),0,e.pageContent.length),this.DEBUG&&console.log(t);let n=e.pageContent.substring(t.start,t.end);this.DEBUG&&console.log(n);let r=e.pageContent.substring(0,t.start),i=e.pageContent.substring(t.end),a=r.split(/s+/).length+i.split(/s+/).length,o=Math.max(1,this.targetSummarisedStringTokenCount-a);this.DEBUG&&console.log(a,o);let s=await this.summariser?.(n,{max_length:o}),c=Array.isArray(s?.[0])?s?.[0]?.[0]:s?.[0];this.DEBUG&&console.log(s,c);let l=r+(c?.summary_text??``).split(/s+/).slice(o).join(` `)+i;return this.DEBUG&&console.log(`Summarised candidate: `+l),l}))).filter(e=>e.status===`fulfilled`&&e.value).map(e=>e.value)}else O=D.map(e=>e.pageContent);if(!g){let e=h(s({problemDescription:t,summaries:O,candidatesForFinalSelection:o,candidateIdentifierField:String(f)}));if(this.DEBUG&&console.log(`Formatted ranking prompt: `+e),this.tokeniser.encode(e).length>this.tokeniser.model_max_length)throw Error(`Ranking instruction prompt is too long for the tokeniser model`);try{let t=await this.generator(e,{max_new_tokens:this.rankingMaxNewTokens,temperature:this.rankingTemperature,repetition_penalty:this.rankingRepetitionPenalty,pad_token_id:S,eos_token_id:C});_=(Array.isArray(t?.[0])?t?.[0]?.[0]:t[0]).generated_text.toString().trim().replace(/(\*\*)|(<\/?s>)|(\[.*?\])\s*/g,``),this.DEBUG&&console.log(`Generated rationale: `+_);let n=_.indexOf(`### Response:`);n>=0?n+=13:n=0,_=_.substring(n)}catch(e){console.log(e),_=``}}if(_){let t=c(_);this.DEBUG&&console.log(`Extracted identifiers from rationale: `+t),t.length>o&&(t=t.slice(0,o)),v=d.default.compact(t.map(t=>p({identifier:t,candidateIdentifierField:f,candidates:e})))}if(!Array.isArray(v)||v.length<o){Array.isArray(v)||(v=[]);let t=d.default.compact(D.map(t=>{let n=u({candidateDocument:t.pageContent,candidateIdentifierField:String(f)});return this.DEBUG&&console.log(`Extracted identifier from candidate document: `+n),p({identifier:n,candidateIdentifierField:f,candidates:e})}));v.splice(v.length,0,...t),v=d.default.uniq(v).slice(0,o-v.length)}return this.DEBUG&&console.log(`Selected candidates`,v),{rationale:_,selectedCandidates:v}}};(function(e){})(p||={});var m=p;Object.defineProperty(exports,`AICompareCandidates`,{enumerable:!0,get:function(){return p}}),exports.default=m;
26
26
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Embeddings","env","AutoTokenizer","matches:string[]","match:RegExpExecArray|null","selectedCandidates:Candidate[]","MemoryVectorStore","summaries:string[]","summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices"],"sources":["../src/index.ts"],"sourcesContent":["import{\n\tenv,\n\tpipeline,\n\tAutoTokenizer,\n\tTextGenerationPipeline,\n\tProgressInfo,\n\tProgressCallback,\n\tSummarizationPipeline,\n\tFeatureExtractionPipeline,\n\tPreTrainedTokenizer,\n\tTextGenerationConfig,\n\tTextGenerationSingle\n}from '@sroussey/transformers';\nimport {MemoryVectorStore} from '@langchain/classic/vectorstores/memory';\nimport {Embeddings} from '@langchain/core/embeddings';\nimport lodash from 'lodash';\nimport jsan from 'jsan';\n\nexport class AICompareCandidates extends Embeddings{\n\treadonly env=env;\n\tDEBUG=true;\n\n\tgenerator:TextGenerationPipeline|null=null;\n\tgeneratorModelName='Xenova/LaMini-GPT-774M';\n\tgeneratorPromise:Promise<TextGenerationPipeline>|null=null;\n\tgeneratorProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tgeneratorProgressCallback:ProgressCallback|null=null;\n\tgeneratorAbortController=new AbortController();\n\n\tsummariser:SummarizationPipeline|null=null;\n\tsummariserModelName='Xenova/distilbart-cnn-12-6';\n\tsummariserPromise:Promise<SummarizationPipeline>|null=null;\n\tsummariserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tsummariserProgressCallback:ProgressCallback|null=null;\n\tsummariserAbortController=new AbortController();\n\n\tembedder:FeatureExtractionPipeline|null=null;\n\tembedderModelName='Xenova/all-MiniLM-L12-v2';\n\tembedderPromise:Promise<FeatureExtractionPipeline>|null=null;\n\tembedderProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tembedderProgressCallback:ProgressCallback|null=null;\n\tembedderAbortController=new AbortController();\n\n\ttokeniser:PreTrainedTokenizer|null=null;\n\ttokeniserModelName=this.generatorModelName;\n\ttokeniserPromise:Promise<PreTrainedTokenizer>|null=null;\n\ttokeniserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\ttokeniserProgressCallback:ProgressCallback|null=null;\n\ttokeniserAbortController=new AbortController();\n\n\tgenerateSearchAreasMaxNewTokens=64;\n\tgenerateSearchAreasTemperature=0.35;\n\tgenerateSearchAreasRepetitionPenalty=1.5;\n\n\trankingMaxNewTokens=64;\n\trankingTemperature=0.35;\n\trankingRepetitionPenalty=1.5;\n\n\ttargetSummarisedStringTokenCount=420;\n\n\tstatic{\n\t\tenv.localModelPath='';\n\t\tenv.allowRemoteModels=true;\n\t\tenv.allowLocalModels=false;\n\t}\n\n\tconstructor(){\n\t\tsuper({});\n\t}\n\t\n\tasync loadGenerator({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.generatorModelName=modelName;\n\t\tif(!this.generatorModelName)throw new Error('Invalid generator model name');\n\t\tif(progressCallback)this.generatorProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.generatorPromise=pipeline('text-generation',this.generatorModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.generatorProgressInfo,progressInfo);\n\t\t\t\treturn this.generatorProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.generatorAbortController.signal\n\t\t});\n\t\tthis.generator=await this.generatorPromise;\n\t\treturn this.generator;\n\t}\n\n\tasync checkGeneratorLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.generatorPromise)this.loadGenerator({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.generator){\n\t\t\ttry{\n\t\t\t\tawait this.generatorPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.generatorPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.generator){\n\t\t\tthis.generatorPromise=null;\n\t\t\tthrow new Error('Unable to load generator');\n\t\t}\n\t}\n\n\tasync abortLoadGenerator(reason?:any){\n\t\tthis.generatorAbortController.abort(reason);\n\t\tthis.generatorAbortController=new AbortController();\n\t}\n\n\tasync loadSummariser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.summariserModelName=modelName;\n\t\tif(!this.summariserModelName)throw new Error('Invalid summariser model name');\n\t\tif(progressCallback)this.summariserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.summariserPromise=pipeline('summarization',this.summariserModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.summariserProgressInfo,progressInfo);\n\t\t\t\treturn this.summariserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.summariserAbortController.signal\n\t\t});\n\t\tthis.summariser=await this.summariserPromise;\n\t\treturn this.summariser;\n\t}\n\n\tasync checkSummariserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.summariserPromise)this.loadSummariser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.summariser){\n\t\t\ttry{\n\t\t\t\tawait this.summariserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.summariserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.summariser){\n\t\t\tthis.summariserPromise=null;\n\t\t\tthrow new Error('Unable to load summariser');\n\t\t}\n\t}\n\n\tasync abortLoadSummariser(){\n\t\tthis.summariserAbortController.abort();\n\t\tthis.summariserAbortController=new AbortController();\n\t}\n\n\tasync loadEmbedder({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.embedderModelName=modelName;\n\t\tif(!this.embedderModelName)throw new Error('Invalid embedder model name');\n\t\tif(progressCallback)this.embedderProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.embedderPromise=pipeline('feature-extraction',this.embedderModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.embedderProgressInfo,progressInfo);\n\t\t\t\treturn this.embedderProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.embedderAbortController.signal\n\t\t});\n\t\tthis.embedder=await this.embedderPromise;\n\t\treturn this.embedder;\n\t}\n\n\tasync checkEmbedderLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.embedderPromise)this.loadEmbedder({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.embedder){\n\t\t\ttry{\n\t\t\t\tawait this.embedderPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.embedderPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.embedder){\n\t\t\tthis.embedderPromise=null;\n\t\t\tthrow new Error('Unable to load embedder');\n\t\t}\n\t}\n\n\tasync abortLoadEmbedder(){\n\t\tthis.embedderAbortController.abort();\n\t\tthis.embedderAbortController=new AbortController();\n\t}\n\n\tasync loadTokeniser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.tokeniserModelName=modelName;\n\t\tif(!this.tokeniserModelName)throw new Error('Invalid tokeniser model name');\n\t\tif(progressCallback)this.tokeniserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.tokeniserPromise=AutoTokenizer.from_pretrained(this.tokeniserModelName,{\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.tokeniserProgressInfo,progressInfo);\n\t\t\t\treturn this.tokeniserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.tokeniserAbortController.signal\n\t\t});\n\t\tthis.tokeniser=await this.tokeniserPromise;\n\t\treturn this.tokeniser;\n\t}\n\n\tasync checkTokeniserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.tokeniserPromise)this.loadTokeniser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.tokeniser){\n\t\t\ttry{\n\t\t\t\tawait this.tokeniserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.tokeniserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.tokeniser){\n\t\t\tthis.tokeniserPromise=null;\n\t\t\tthrow new Error('Unable to load tokeniser');\n\t\t}\n\t}\n\n\tasync abortLoadTokeniser(){\n\t\tthis.tokeniserAbortController.abort();\n\t\tthis.tokeniserAbortController=new AbortController();\n\t}\n\n\tasync embedQuery(text:string):Promise<number[]>{\n\t\tawait this.checkEmbedderLoaded();\n\t\treturn Array.from((await this.embedder?.(text,{\n\t\t\tpooling:'mean',\n\t\t\tnormalize:true\n\t\t}))?.data);\n\t}\n\n\tasync embedDocuments(texts:string[]):Promise<number[][]>{\n\t\treturn Promise.all(texts.map(text=>this.embedQuery(text)));\n\t}\n\n\tdefaultGeneratePromptTemplate(prompt:string){\n\t\treturn 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n'+\n\t\t\t'### Instruction:\\n'+\n\t\t\tprompt+\n\t\t\t'\\n\\n### Response:';\n\t}\n\n\tdefaultGenerateSearchAreasInstruction(problemDescription:string){\n\t\treturn 'List the relevant subject areas for the following issues. Limit your response to 100 words.\\nIssues: \"'+problemDescription+'\"';\n\t}\n\n\tdefaultConvertCandidateToDocument<Candidate>({\n\t\tcandidate,\n\t\tindex\n\t}:AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>=<AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>>{}){\n\t\tlet document='Start of Candidate #'+index;\n\t\tfor(let i in candidate)document+='\\n'+lodash.startCase(i)+': '+(typeof candidate[i]==='object'?jsan.stringify(candidate[i]):String(candidate[i]));\n\t\tdocument+='\\nEnd of Candidate #'+index;\n\t\treturn document;\n\t}\n\n\tdefaultGenerateRankingInstruction({\n\t\tproblemDescription,\n\t\tsummaries,\n\t\tcandidatesForFinalSelection,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.GenerateRankingInstructionArguments=<AICompareCandidates.GenerateRankingInstructionArguments>{}){\n\t\treturn 'Strictly follow these rules:\\n'+\n\t\t\t'1. Rank ONLY the top '+candidatesForFinalSelection+' candidates with one 15-word sentence explaining why\\n'+\n\t\t\t'2. Rank the candidates based on \"'+problemDescription.replace(/(\\r|\\n)/g,' ')+'\"\\n'+\n\t\t\t'3. If unclear, say \"Insufficient information to determine\"\\n\\n'+\n\t\t\t'Candidates:\\n\\n'+summaries.join('\\n\\n')+'\\n\\n'+\n\t\t\t'Format exactly:\\n'+\n\t\t\t'#1. \"Full '+lodash.startCase(candidateIdentifierField)+'\": 15-word explanation\\n'+\n\t\t\t'#2. ...';\n\t}\n\n\tregexIndexOf(text:string,regex:RegExp,startIndex:number){\n \tlet indexInSuffix=text.slice(startIndex).search(regex);\n \treturn indexInSuffix<0?indexInSuffix:indexInSuffix+startIndex;\n\t}\n\n\tdefaultExtractIdentifierFromCandidateDocument({\n\t\tcandidateDocument,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments=<AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments>{}){\n\t\tif(this.DEBUG)console.log(candidateDocument,candidateIdentifierField);\n\t\tlet startCase=lodash.startCase(candidateIdentifierField);\n\t\tlet startIndex=candidateDocument.indexOf(startCase);\n\t\tif(startIndex<0)startIndex=candidateDocument.toLowerCase().indexOf(startCase.toLowerCase());\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex>=0)startIndex+=startCase.length;\n\t\tif(startIndex<0){\n\t\t\tstartIndex=candidateDocument.toLowerCase().indexOf(candidateIdentifierField.toLowerCase());\n\t\t\tif(startIndex>=0)startIndex+=candidateIdentifierField.length;\n\t\t}\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\telse return '';\n\t\tstartIndex=candidateDocument.indexOf(':',startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)startIndex=this.regexIndexOf(candidateDocument,/\\s+/,startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)return '';\n\t\tlet endIndex=candidateDocument.indexOf('\\n',startIndex);\n\t\tif(endIndex<0)endIndex=candidateDocument.length;\n\t\tif(this.DEBUG)console.log(endIndex);\n\t\treturn candidateDocument.substring(startIndex,endIndex).trim();\n\t}\n\n\tdefaultExtractIdentifiersFromRationale(rationale:string){\n\t\tlet regex=/^\\s*#\\s*\\d+\\s*\\.?\\s*\"([^\"]+)\"/gm;\n\t\tlet matches:string[]=[];\n\t\tfor(let match:RegExpExecArray|null;Array.isArray(match=regex.exec(rationale));)if(match[1])matches.push(match[1]);\n\t\treturn matches;\n\t}\n\n\tdefaultFindCandidateFromIdentifier<Candidate>({\n\t\tidentifier,\n\t\tcandidateIdentifierField,\n\t\tcandidates\n\t}:AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>=<AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>>{}){\n\t\tlet selectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase()===identifier.toLowerCase());\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase().includes(identifier.toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>identifier.toLowerCase().includes(String(candidate[candidateIdentifierField]).toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\t//split by space and find highest number of matches (tie break if it is in same order)\n\t\tlet identifierWords=identifier.split(/\\s+/g);\n\t\tlet selectedCandidates=candidates.map(candidate=>({\n\t\t\tidentifierWordIndices:identifierWords.map(identifierWord=>String(candidate[candidateIdentifierField]).indexOf(identifierWord)),\n\t\t\tcandidate\n\t\t})).sort((a,b)=>{\n\t\t\tlet aCount=lodash.sumBy(a.identifierWordIndices,aElement=>aElement<0?0:1);\n\t\t\tlet bCount=lodash.sumBy(b.identifierWordIndices,bElement=>bElement<0?0:1);\n\t\t\tif(aCount!==bCount)return bCount-aCount;\n\t\t\tif(aCount===0&&bCount===0)return 0;\n\t\t\taCount=0;\n\t\t\tbCount=0;\n\t\t\tfor(let i=0;i<a.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<a.identifierWordIndices.length;++j){\n\t\t\t\t\tif(a.identifierWordIndices[i]<0||a.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(a.identifierWordIndices[i]<a.identifierWordIndices[j])++aCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(let i=0;i<b.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<b.identifierWordIndices.length;++j){\n\t\t\t\t\tif(b.identifierWordIndices[i]<0||b.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(b.identifierWordIndices[i]<b.identifierWordIndices[j])++bCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bCount-aCount;\n\t\t});\n\t\tif(selectedCandidates[0].identifierWordIndices.some(index=>index>=0))return selectedCandidates[0].candidate;\n\t\treturn null;\n\t}\n\n\tdefaultParseSearchAreasResponse(searchAreasResponse:string){\n\t\tlet searchAreasResponseIndex=String(searchAreasResponse).indexOf('### Response:');\n\t\tif(searchAreasResponseIndex>=0)searchAreasResponseIndex+='### Response:'.length;\n\t\telse searchAreasResponseIndex=0;\n\t\treturn String(searchAreasResponse).substring(searchAreasResponseIndex).trim();\n\t}\n\n\tasync compareCandidates<Candidate>({\n\t\tcandidates,\n\t\tproblemDescription='',\n\t\tgenerateSearchAreasInstruction=this.defaultGenerateSearchAreasInstruction.bind(this),\n\t\tparseSearchAreasResponse=this.defaultParseSearchAreasResponse.bind(this),\n\t\tconvertCandidateToDocument=this.defaultConvertCandidateToDocument.bind(this),\n\t\tcandidatesForInitialSelection=2,\n\t\tcandidatesForFinalSelection=1,\n\t\tgenerateRankingInstruction=this.defaultGenerateRankingInstruction.bind(this),\n\t\textractIdentifiersFromRationale=this.defaultExtractIdentifiersFromRationale.bind(this),\n\t\textractIdentifierFromCandidateDocument=this.defaultExtractIdentifierFromCandidateDocument.bind(this),\n\t\tcandidateIdentifierField=undefined,\n\t\tfindCandidateFromIdentifier=this.defaultFindCandidateFromIdentifier.bind(this),\n\t\tgetSummarisableSubstringIndices,\n\t\tgeneratePromptTemplate=this.defaultGeneratePromptTemplate.bind(this),\n\t\tskipRationale=false\n\t}:AICompareCandidates.CompareArguments<Candidate>=<AICompareCandidates.CompareArguments<Candidate>>{}):Promise<AICompareCandidates.CompareCandidatesReturn<Candidate>|void>{\n\t\tif(!Array.isArray(candidates)||candidates.length<=0)throw new Error('No candidates provided');\n\t\tcandidatesForInitialSelection=lodash.toSafeInteger(candidatesForInitialSelection);\n\t\tif(candidatesForInitialSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tcandidatesForFinalSelection=lodash.toSafeInteger(candidatesForFinalSelection);\n\t\tif(candidatesForFinalSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tif(candidatesForInitialSelection<candidatesForFinalSelection)throw new Error('Candidates for initial selection must be equal or more than candidates for final selection');\n\t\tif(candidatesForInitialSelection>candidates.length)throw new Error('There are '+candidatesForInitialSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(candidatesForFinalSelection>candidates.length)throw new Error('There are '+candidatesForFinalSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(!candidateIdentifierField){\n\t\t\tcandidateIdentifierField=Object.keys(candidates[0] as object)[0] as keyof Candidate;\n\t\t\tif(!candidateIdentifierField)throw new Error('No candidate identifier field');\n\t\t}\n\n\t\tlet rationale='';\n\t\tlet selectedCandidates:Candidate[]=[];\n\n\t\tawait this.checkEmbedderLoaded();\n\t\tif(!this.embedder)return;\n\t\tlet candidateDocuments=candidates.map((candidate,index)=>convertCandidateToDocument({\n\t\t\tcandidate,\n\t\t\tindex\n\t\t}));\n\t\tlet vectorStore=await MemoryVectorStore.fromTexts(\n\t\t\tlodash.cloneDeep(candidateDocuments),\n\t\t\tcandidateDocuments.map((document,index)=>index),\n\t\t\tthis\n\t\t);\n\n\t\tlet searchAreasPromptTemplate=generatePromptTemplate(generateSearchAreasInstruction(problemDescription));\n\t\tif(this.DEBUG)console.log('Formatted search areas prompt: '+searchAreasPromptTemplate);\n\t\tawait this.checkTokeniserLoaded();\n\t\tif(!this.tokeniser)return;\n\t\tlet searchAreasPromptTokens=this.tokeniser.encode(searchAreasPromptTemplate);\n\t\tif(searchAreasPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Search areas instruction prompt is too long for the tokeniser model');\n\n\t\tawait this.checkGeneratorLoaded();\n\t\tif(!this.generator)return;\n\t\tlet pad_token_id=this.tokeniser.pad_token_id??this.tokeniser.sep_token_id??0;\n\t\tlet eos_token_id=this.tokeniser.sep_token_id??2;\n\t\tlet searchAreasReplyArray=await this.generator(searchAreasPromptTemplate,{\n\t\t\tmax_new_tokens:this.generateSearchAreasMaxNewTokens,\n\t\t\ttemperature:this.generateSearchAreasTemperature,\n\t\t\trepetition_penalty:this.generateSearchAreasRepetitionPenalty,\n\t\t\tpad_token_id,\n\t\t\teos_token_id\n\t\t});\n\t\tlet searchAreasReply=Array.isArray(searchAreasReplyArray?.[0])?searchAreasReplyArray?.[0]?.[0]:searchAreasReplyArray?.[0];\n\t\tif(!searchAreasReply.generated_text)throw new Error('No generated text for search areas');\n\t\tif(this.DEBUG)console.log('Generated search areas response: '+searchAreasReply.generated_text);\n\t\tlet vectorSearchQuery=parseSearchAreasResponse(Array.isArray(searchAreasReply.generated_text)?searchAreasReply.generated_text.join('\\n\\n'):String(searchAreasReply.generated_text));\n\t\t//generally the first sentence has the greatest relevance to the actual prompt\n\t\t//if(vectorSearchQuery.includes('.'))vectorSearchQuery=vectorSearchQuery.split('.')[0].trim();\n\t\tif(this.DEBUG)console.log('Vector search query: '+vectorSearchQuery);\n\t\tlet queryResult=await vectorStore.similaritySearch(vectorSearchQuery,candidatesForInitialSelection);\n\t\tif(this.DEBUG)console.log('Vector search results: ',queryResult);\n\n\t\tlet summaries:string[]=[];\n\t\t//only bother doing summarisation if there are candidates which exceed the token count\n\t\tif(queryResult.some(result=>result.pageContent.trim().split(/\\s+/).length>this.targetSummarisedStringTokenCount)){\n\t\t\tawait this.checkSummariserLoaded();\n\t\t\tif(!this.summariser)return;\n\t\t\tsummaries=(await Promise.allSettled(queryResult.map(async result=>{\n\t\t\t\tif(!result.pageContent||typeof result.pageContent!=='string')return '';\n\t\t\t\tif(result.pageContent.trim().split(/\\s+/).length<=this.targetSummarisedStringTokenCount)return result.pageContent;\n\t\t\t\tlet summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices={\n\t\t\t\t\tstart:0,\n\t\t\t\t\tend:result.pageContent.length\n\t\t\t\t};\n\t\t\t\tif(getSummarisableSubstringIndices)Object.assign(summarisableSubstringIndices,getSummarisableSubstringIndices(result.pageContent));\n\t\t\t\tsummarisableSubstringIndices.start=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.start),0,result.pageContent.length);\n\t\t\t\tsummarisableSubstringIndices.end=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.end),0,result.pageContent.length);\n\t\t\t\tlet summarisableSubstring=result.pageContent.substring(summarisableSubstringIndices.start,summarisableSubstringIndices.end);\n\t\t\t\tlet contentBefore=result.pageContent.substring(0,summarisableSubstringIndices.start);\n\t\t\t\tlet contentAfter=result.pageContent.substring(summarisableSubstringIndices.end);\n\t\t\t\tlet wordsWithoutSummarisable=contentBefore.split(/s+/).length+contentAfter.split(/s+/).length;\n\t\t\t\tlet targetSummarisedSubstringTokenCount=Math.max(1,this.targetSummarisedStringTokenCount-wordsWithoutSummarisable);\n\t\t\t\tlet summarisedSubstringArray=await this.summariser?.(summarisableSubstring,<TextGenerationConfig>{\n\t\t\t\t\tmax_length:targetSummarisedSubstringTokenCount\n\t\t\t\t});\n\t\t\t\tlet summarisedSubstring=Array.isArray(summarisedSubstringArray?.[0])?summarisedSubstringArray?.[0]?.[0]:summarisedSubstringArray?.[0];\n\t\t\t\tlet summarisedString=contentBefore+(summarisedSubstring?.summary_text??'').split(/s+/).slice(targetSummarisedSubstringTokenCount).join(' ')+contentAfter;\n\t\t\t\tif(this.DEBUG)console.log('Summarised candidate: '+summarisedString);\n\t\t\t\treturn summarisedString;\n\t\t\t}))).filter(result=>result.status==='fulfilled'&&result.value).map(result=>(result as PromiseFulfilledResult<string>).value);\n\t\t}else{\n\t\t\tsummaries=queryResult.map(result=>result.pageContent);\n\t\t}\n\n\t\tif(!skipRationale){\n\t\t\tlet rankingPromptTemplate=generatePromptTemplate(generateRankingInstruction({\n\t\t\t\tproblemDescription,\n\t\t\t\tsummaries,\n\t\t\t\tcandidatesForFinalSelection,\n\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t}));\n\t\t\tif(this.DEBUG)console.log('Formatted ranking prompt: '+rankingPromptTemplate);\n\t\t\tlet rankingPromptTokens=this.tokeniser.encode(rankingPromptTemplate);\n\t\t\tif(rankingPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Ranking instruction prompt is too long for the tokeniser model');\n\t\t\ttry{\n\t\t\t\tlet rankingArray=await this.generator(rankingPromptTemplate,{\n\t\t\t\t\tmax_new_tokens:this.rankingMaxNewTokens,\n\t\t\t\t\ttemperature:this.rankingTemperature,\n\t\t\t\t\trepetition_penalty:this.rankingRepetitionPenalty,\n\t\t\t\t\tpad_token_id,\n\t\t\t\t\teos_token_id\n\t\t\t\t});\n\t\t\t\tlet ranking=Array.isArray(rankingArray?.[0])?rankingArray?.[0]?.[0]:rankingArray[0];\n\t\t\t\trationale=ranking.generated_text.toString().trim().replace(/(\\*\\*)|(<\\/?s>)|(\\[.*?\\])\\s*/g, '');\n\t\t\t\tif(this.DEBUG)console.log('Generated rationale: '+rationale);\n\t\t\t\tlet rationaleResponseIndex=rationale.indexOf('### Response:');\n\t\t\t\tif(rationaleResponseIndex>=0)rationaleResponseIndex+='### Response:'.length;\n\t\t\t\telse rationaleResponseIndex=0;\n\t\t\t\trationale=rationale.substring(rationaleResponseIndex);\n\t\t\t\t//if(!rationale)throw new Error('No rationale generated');\n\t\t\t}catch(error){\n\t\t\t\tconsole.log(error);\n\t\t\t\trationale='';\n\t\t\t}\n\t\t}\n\n\t\tif(rationale){\n\t\t\tlet identifiers=extractIdentifiersFromRationale(rationale);\n\t\t\tif(this.DEBUG)console.log('Extracted identifiers from rationale: '+identifiers);\n\t\t\tif(identifiers.length>candidatesForFinalSelection)identifiers=identifiers.slice(0,candidatesForFinalSelection);\n\t\t\tselectedCandidates=lodash.compact(identifiers.map(identifier=>findCandidateFromIdentifier({\n\t\t\t\tidentifier,\n\t\t\t\tcandidateIdentifierField,\n\t\t\t\tcandidates\n\t\t\t})));\n\t\t}\n\n\t\tif(!Array.isArray(selectedCandidates)||selectedCandidates.length<candidatesForFinalSelection){\n\t\t\tif(!Array.isArray(selectedCandidates))selectedCandidates=[];\n\t\t\tlet additionalSelectedCandidates=lodash.compact(queryResult.map(result=>{\n\t\t\t\tlet identifier=extractIdentifierFromCandidateDocument({\n\t\t\t\t\tcandidateDocument:result.pageContent,\n\t\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t\t});\n\t\t\t\tif(this.DEBUG)console.log('Extracted identifier from candidate document: '+identifier);\n\t\t\t\treturn findCandidateFromIdentifier({\n\t\t\t\t\tidentifier,\n\t\t\t\t\tcandidateIdentifierField,\n\t\t\t\t\tcandidates\n\t\t\t\t});\n\t\t\t}));\n\t\t\tselectedCandidates.splice(selectedCandidates.length,0,...additionalSelectedCandidates);\n\t\t\tselectedCandidates=lodash.uniq(selectedCandidates).slice(0,candidatesForFinalSelection-selectedCandidates.length);\n\t\t}\n\t\tif(this.DEBUG)console.log('Selected candidates',selectedCandidates);\n\n\t\treturn{\n\t\t\trationale,\n\t\t\tselectedCandidates\n\t\t};\n\t}\n};\n\nexport namespace AICompareCandidates{\n\texport interface LoadArguments{\n\t\tprogressCallback?:ProgressCallback;\n\t\tmodelName?:string;\n\t};\n\n\texport interface SummarisableSubstringIndices{\n\t\tstart:number;\n\t\tend:number;\n\t};\n\n\texport interface CompareArguments<Candidate>{\n\t\tcandidates:Candidate[];\n\t\tproblemDescription:string;\n\t\tgenerateSearchAreasInstruction?:(problemDescription:string)=>string;\n\t\tparseSearchAreasResponse?:(searchAreasResponse:string)=>string;\n\t\tconvertCandidateToDocument?:(convertCandidateToDocumentArguments:ConvertCandidateToDocumentArguments<Candidate>)=>string;\n\t\tcandidatesForInitialSelection?:number;\n\t\tcandidatesForFinalSelection?:number;\n\t\tgenerateRankingInstruction?:(generateRankingInstructionArguments:GenerateRankingInstructionArguments)=>string;\n\t\textractIdentifiersFromRationale?:(rationale:string)=>string[];\n\t\textractIdentifierFromCandidateDocument?:(extractIdentifierFromCandidateDocumentArguments:ExtractIdentifierFromCandidateDocumentArguments)=>string;\n\t\tcandidateIdentifierField?:keyof Candidate;\n\t\tfindCandidateFromIdentifier?:(findCandidateFromIdentifierArguments:FindCandidateFromIdentifierArguments<Candidate>)=>Candidate|null;\n\t\tgetSummarisableSubstringIndices?:(candidateDocument:string)=>SummarisableSubstringIndices;\n\t\tgeneratePromptTemplate?:(prompt:string)=>string;\n\t\tskipRationale?:boolean;\n\t};\n\n\texport interface ConvertCandidateToDocumentArguments<Candidate>{\n\t\tcandidate:Candidate;\n\t\tindex:number;\n\t};\n\n\texport interface ExtractIdentifierFromCandidateDocumentArguments{\n\t\tcandidateDocument:string;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface FindCandidateFromIdentifierArguments<Candidate>{\n\t\tidentifier:string;\n\t\tcandidateIdentifierField:keyof Candidate;\n\t\tcandidates:Candidate[];\n\t};\n\n\texport interface GenerateRankingInstructionArguments{\n\t\tproblemDescription:string;\n\t\tsummaries:string[];\n\t\tcandidatesForFinalSelection:number;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface CompareCandidatesReturn<Candidate>{\n\t\tselectedCandidates:Candidate[],\n\t\trationale:string\n\t};\n};\n\nexport default AICompareCandidates;"],"mappings":"itBAkBA,IAAa,EAAb,cAAyCA,EAAAA,UAAU,CAClD,IAAaC,EAAAA,IACb,MAAM,GAEN,UAAsC,KACtC,mBAAmB,yBACnB,iBAAsD,KACtD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE7B,WAAsC,KACtC,oBAAoB,6BACpB,kBAAsD,KACtD,uBAAkD,EAAE,CACpD,2BAAiD,KACjD,0BAA0B,IAAI,gBAE9B,SAAwC,KACxC,kBAAkB,2BAClB,gBAAwD,KACxD,qBAAgD,EAAE,CAClD,yBAA+C,KAC/C,wBAAwB,IAAI,gBAE5B,UAAmC,KACnC,mBAAmB,KAAK,mBACxB,iBAAmD,KACnD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE7B,gCAAgC,GAChC,+BAA+B,IAC/B,qCAAqC,IAErC,oBAAoB,GACpB,mBAAmB,IACnB,yBAAyB,IAEzB,iCAAiC,IAEjC,OACC,EAAA,IAAI,eAAe,GACnB,EAAA,IAAI,kBAAkB,GACtB,EAAA,IAAI,iBAAiB,GAGtB,aAAa,CACZ,MAAM,EAAE,CAAC,CAGV,MAAM,cAAc,CACnB,mBACA,YAAU,IAC4D,EAAE,CAAC,CAEzE,GADG,OAAO,GAAY,UAAU,IAAU,KAAK,mBAAmB,GAC/D,CAAC,KAAK,mBAAmB,MAAU,MAAM,+BAA+B,CAc3E,OAb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EAAM,CAClB,EAAU,IAIZ,GAAG,EAAU,CACZ,IAAI,EAAY,EAAgC,EAAU,CACvD,KAAK,OAAM,QAAQ,IAAI,yCAAyC,EAAY,CAC5E,EAAY,OAAO,IAA4B,EAAY,EAAY,MAAM,EAAE,EAA4B,EAC9G,EAAmB,EAAA,QAAO,QAAQ,EAAY,IAAI,GAAY,EAA4B,CACzF,aACA,2BACA,aACA,CAAC,CAAC,CAAC,CAGL,GAAG,CAAC,MAAM,QAAQ,EAAmB,EAAE,EAAmB,OAAO,EAA4B,CACxF,MAAM,QAAQ,EAAmB,GAAC,EAAmB,EAAE,EAC3D,IAAI,EAA6B,EAAA,QAAO,QAAQ,EAAY,IAAI,GAAQ,CACvE,IAAI,EAAW,EAAuC,CACrD,kBAAkB,EAAO,YACzB,yBAAyB,OAAO,EAAyB,CACzD,CAAC,CAEF,OADG,KAAK,OAAM,QAAQ,IAAI,iDAAiD,EAAW,CAC/E,EAA4B,CAClC,aACA,2BACA,aACA,CAAC,EACD,CAAC,CACH,EAAmB,OAAO,EAAmB,OAAO,EAAE,GAAG,EAA6B,CACtF,EAAmB,EAAA,QAAO,KAAK,EAAmB,CAAC,MAAM,EAAE,EAA4B,EAAmB,OAAO,CAIlH,OAFG,KAAK,OAAM,QAAQ,IAAI,sBAAsB,EAAmB,CAE7D,CACL,YACA,qBACA,2BA8DH,IAAA,EAAe"}
1
+ {"version":3,"file":"index.cjs","names":["Embeddings","env","AutoTokenizer","matches:string[]","match:RegExpExecArray|null","selectedCandidates:Candidate[]","MemoryVectorStore","summaries:string[]","summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices"],"sources":["../src/index.ts"],"sourcesContent":["import{\n\tenv,\n\tpipeline,\n\tAutoTokenizer,\n\tTextGenerationPipeline,\n\tProgressInfo,\n\tProgressCallback,\n\tSummarizationPipeline,\n\tFeatureExtractionPipeline,\n\tPreTrainedTokenizer,\n\tTextGenerationConfig,\n\tTextGenerationSingle\n}from '@sroussey/transformers';\nimport {MemoryVectorStore} from '@langchain/classic/vectorstores/memory';\nimport {Embeddings} from '@langchain/core/embeddings';\nimport lodash from 'lodash';\nimport jsan from 'jsan';\n\nexport class AICompareCandidates extends Embeddings{\n\treadonly env=env;\n\tDEBUG=true;\n\n\tgenerator:TextGenerationPipeline|null=null;\n\tgeneratorModelName='Xenova/LaMini-GPT-774M';\n\tgeneratorPromise:Promise<TextGenerationPipeline>|null=null;\n\tgeneratorProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tgeneratorProgressCallback:ProgressCallback|null=null;\n\tgeneratorAbortController=new AbortController();\n\n\tsummariser:SummarizationPipeline|null=null;\n\tsummariserModelName='Xenova/distilbart-cnn-12-6';\n\tsummariserPromise:Promise<SummarizationPipeline>|null=null;\n\tsummariserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tsummariserProgressCallback:ProgressCallback|null=null;\n\tsummariserAbortController=new AbortController();\n\n\tembedder:FeatureExtractionPipeline|null=null;\n\tembedderModelName='Xenova/all-MiniLM-L12-v2';\n\tembedderPromise:Promise<FeatureExtractionPipeline>|null=null;\n\tembedderProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tembedderProgressCallback:ProgressCallback|null=null;\n\tembedderAbortController=new AbortController();\n\n\ttokeniser:PreTrainedTokenizer|null=null;\n\ttokeniserModelName=this.generatorModelName;\n\ttokeniserPromise:Promise<PreTrainedTokenizer>|null=null;\n\ttokeniserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\ttokeniserProgressCallback:ProgressCallback|null=null;\n\ttokeniserAbortController=new AbortController();\n\n\tgenerateSearchAreasMaxNewTokens=64;\n\tgenerateSearchAreasTemperature=0.35;\n\tgenerateSearchAreasRepetitionPenalty=1.5;\n\n\trankingMaxNewTokens=64;\n\trankingTemperature=0.35;\n\trankingRepetitionPenalty=1.5;\n\n\ttargetSummarisedStringTokenCount=420;\n\n\tstatic{\n\t\tenv.localModelPath='';\n\t\tenv.allowRemoteModels=true;\n\t\tenv.allowLocalModels=false;\n\t}\n\n\tconstructor(){\n\t\tsuper({});\n\t}\n\t\n\tasync loadGenerator({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.generatorModelName=modelName;\n\t\tif(!this.generatorModelName)throw new Error('Invalid generator model name');\n\t\tif(progressCallback)this.generatorProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.generatorPromise=pipeline('text-generation',this.generatorModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.generatorProgressInfo,progressInfo);\n\t\t\t\treturn this.generatorProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.generatorAbortController.signal\n\t\t});\n\t\tthis.generator=await this.generatorPromise;\n\t\treturn this.generator;\n\t}\n\n\tasync checkGeneratorLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.generatorPromise)this.loadGenerator({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.generator){\n\t\t\ttry{\n\t\t\t\tawait this.generatorPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.generatorPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.generator){\n\t\t\tthis.generatorPromise=null;\n\t\t\tthrow new Error('Unable to load generator');\n\t\t}\n\t}\n\n\tasync abortLoadGenerator(reason?:any){\n\t\tthis.generatorAbortController.abort(reason);\n\t\tthis.generatorAbortController=new AbortController();\n\t}\n\n\tasync loadSummariser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.summariserModelName=modelName;\n\t\tif(!this.summariserModelName)throw new Error('Invalid summariser model name');\n\t\tif(progressCallback)this.summariserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.summariserPromise=pipeline('summarization',this.summariserModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.summariserProgressInfo,progressInfo);\n\t\t\t\treturn this.summariserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.summariserAbortController.signal\n\t\t});\n\t\tthis.summariser=await this.summariserPromise;\n\t\treturn this.summariser;\n\t}\n\n\tasync checkSummariserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.summariserPromise)this.loadSummariser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.summariser){\n\t\t\ttry{\n\t\t\t\tawait this.summariserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.summariserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.summariser){\n\t\t\tthis.summariserPromise=null;\n\t\t\tthrow new Error('Unable to load summariser');\n\t\t}\n\t}\n\n\tasync abortLoadSummariser(){\n\t\tthis.summariserAbortController.abort();\n\t\tthis.summariserAbortController=new AbortController();\n\t}\n\n\tasync loadEmbedder({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.embedderModelName=modelName;\n\t\tif(!this.embedderModelName)throw new Error('Invalid embedder model name');\n\t\tif(progressCallback)this.embedderProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.embedderPromise=pipeline('feature-extraction',this.embedderModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.embedderProgressInfo,progressInfo);\n\t\t\t\treturn this.embedderProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.embedderAbortController.signal\n\t\t});\n\t\tthis.embedder=await this.embedderPromise;\n\t\treturn this.embedder;\n\t}\n\n\tasync checkEmbedderLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.embedderPromise)this.loadEmbedder({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.embedder){\n\t\t\ttry{\n\t\t\t\tawait this.embedderPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.embedderPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.embedder){\n\t\t\tthis.embedderPromise=null;\n\t\t\tthrow new Error('Unable to load embedder');\n\t\t}\n\t}\n\n\tasync abortLoadEmbedder(){\n\t\tthis.embedderAbortController.abort();\n\t\tthis.embedderAbortController=new AbortController();\n\t}\n\n\tasync loadTokeniser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.tokeniserModelName=modelName;\n\t\tif(!this.tokeniserModelName)throw new Error('Invalid tokeniser model name');\n\t\tif(progressCallback)this.tokeniserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.tokeniserPromise=AutoTokenizer.from_pretrained(this.tokeniserModelName,{\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.tokeniserProgressInfo,progressInfo);\n\t\t\t\treturn this.tokeniserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.tokeniserAbortController.signal\n\t\t});\n\t\tthis.tokeniser=await this.tokeniserPromise;\n\t\treturn this.tokeniser;\n\t}\n\n\tasync checkTokeniserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.tokeniserPromise)this.loadTokeniser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.tokeniser){\n\t\t\ttry{\n\t\t\t\tawait this.tokeniserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.tokeniserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.tokeniser){\n\t\t\tthis.tokeniserPromise=null;\n\t\t\tthrow new Error('Unable to load tokeniser');\n\t\t}\n\t}\n\n\tasync abortLoadTokeniser(){\n\t\tthis.tokeniserAbortController.abort();\n\t\tthis.tokeniserAbortController=new AbortController();\n\t}\n\n\tasync embedQuery(text:string):Promise<number[]>{\n\t\tawait this.checkEmbedderLoaded();\n\t\treturn Array.from((await this.embedder?.(text,{\n\t\t\tpooling:'mean',\n\t\t\tnormalize:true\n\t\t}))?.data);\n\t}\n\n\tasync embedDocuments(texts:string[]):Promise<number[][]>{\n\t\treturn Promise.all(texts.map(text=>this.embedQuery(text)));\n\t}\n\n\tdefaultGeneratePromptTemplate(prompt:string){\n\t\treturn 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n'+\n\t\t\t'### Instruction:\\n'+\n\t\t\tprompt+\n\t\t\t'\\n\\n### Response:';\n\t}\n\n\tdefaultGenerateSearchAreasInstruction(problemDescription:string){\n\t\treturn 'List the relevant subject areas for the following issues. Limit your response to 100 words.\\nIssues: \"'+problemDescription+'\"';\n\t}\n\n\tdefaultConvertCandidateToDocument<Candidate>({\n\t\tcandidate,\n\t\tindex\n\t}:AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>=<AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>>{}){\n\t\tlet document='Start of Candidate #'+index;\n\t\tfor(let i in candidate)document+='\\n'+lodash.startCase(i)+': '+(typeof candidate[i]==='object'?jsan.stringify(candidate[i]):String(candidate[i]));\n\t\tdocument+='\\nEnd of Candidate #'+index;\n\t\treturn document;\n\t}\n\n\tdefaultGenerateRankingInstruction({\n\t\tproblemDescription,\n\t\tsummaries,\n\t\tcandidatesForFinalSelection,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.GenerateRankingInstructionArguments=<AICompareCandidates.GenerateRankingInstructionArguments>{}){\n\t\treturn 'Strictly follow these rules:\\n'+\n\t\t\t'1. Rank ONLY the top '+candidatesForFinalSelection+' candidates with one 15-word sentence explaining why\\n'+\n\t\t\t'2. Rank the candidates based on \"'+problemDescription.replace(/(\\r|\\n)/g,' ')+'\"\\n'+\n\t\t\t'3. If unclear, say \"Insufficient information to determine\"\\n\\n'+\n\t\t\t'Candidates:\\n\\n'+summaries.join('\\n\\n')+'\\n\\n'+\n\t\t\t'Format exactly:\\n'+\n\t\t\t'#1. \"Full '+lodash.startCase(candidateIdentifierField)+'\": 15-word explanation\\n'+\n\t\t\t'#2. ...';\n\t}\n\n\tregexIndexOf(text:string,regex:RegExp,startIndex:number){\n \tlet indexInSuffix=text.slice(startIndex).search(regex);\n \treturn indexInSuffix<0?indexInSuffix:indexInSuffix+startIndex;\n\t}\n\n\tdefaultExtractIdentifierFromCandidateDocument({\n\t\tcandidateDocument,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments=<AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments>{}){\n\t\tif(this.DEBUG)console.log(candidateDocument,candidateIdentifierField);\n\t\tlet startCase=lodash.startCase(candidateIdentifierField);\n\t\tlet startIndex=candidateDocument.indexOf(startCase);\n\t\tif(startIndex<0)startIndex=candidateDocument.toLowerCase().indexOf(startCase.toLowerCase());\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex>=0)startIndex+=startCase.length;\n\t\tif(startIndex<0){\n\t\t\tstartIndex=candidateDocument.toLowerCase().indexOf(candidateIdentifierField.toLowerCase());\n\t\t\tif(startIndex>=0)startIndex+=candidateIdentifierField.length;\n\t\t}\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\telse return '';\n\t\tstartIndex=candidateDocument.indexOf(':',startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)startIndex=this.regexIndexOf(candidateDocument,/\\s+/,startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)return '';\n\t\tlet endIndex=candidateDocument.indexOf('\\n',startIndex);\n\t\tif(endIndex<0)endIndex=candidateDocument.length;\n\t\tif(this.DEBUG)console.log(endIndex);\n\t\treturn candidateDocument.substring(startIndex,endIndex).trim();\n\t}\n\n\tdefaultExtractIdentifiersFromRationale(rationale:string){\n\t\tlet regex=/^\\s*#\\s*\\d+\\s*\\.?\\s*\"([^\"]+)\"/gm;\n\t\tlet matches:string[]=[];\n\t\tfor(let match:RegExpExecArray|null;Array.isArray(match=regex.exec(rationale));)if(match[1])matches.push(match[1]);\n\t\treturn matches;\n\t}\n\n\tdefaultFindCandidateFromIdentifier<Candidate>({\n\t\tidentifier,\n\t\tcandidateIdentifierField,\n\t\tcandidates\n\t}:AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>=<AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>>{}){\n\t\tlet selectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase()===identifier.toLowerCase());\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase().includes(identifier.toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>identifier.toLowerCase().includes(String(candidate[candidateIdentifierField]).toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\t//split by space and find highest number of matches (tie break if it is in same order)\n\t\tlet identifierWords=identifier.split(/\\s+/g);\n\t\tlet selectedCandidates=candidates.map(candidate=>({\n\t\t\tidentifierWordIndices:identifierWords.map(identifierWord=>String(candidate[candidateIdentifierField]).indexOf(identifierWord)),\n\t\t\tcandidate\n\t\t})).sort((a,b)=>{\n\t\t\tlet aCount=lodash.sumBy(a.identifierWordIndices,aElement=>aElement<0?0:1);\n\t\t\tlet bCount=lodash.sumBy(b.identifierWordIndices,bElement=>bElement<0?0:1);\n\t\t\tif(aCount!==bCount)return bCount-aCount;\n\t\t\tif(aCount===0&&bCount===0)return 0;\n\t\t\taCount=0;\n\t\t\tbCount=0;\n\t\t\tfor(let i=0;i<a.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<a.identifierWordIndices.length;++j){\n\t\t\t\t\tif(a.identifierWordIndices[i]<0||a.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(a.identifierWordIndices[i]<a.identifierWordIndices[j])++aCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(let i=0;i<b.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<b.identifierWordIndices.length;++j){\n\t\t\t\t\tif(b.identifierWordIndices[i]<0||b.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(b.identifierWordIndices[i]<b.identifierWordIndices[j])++bCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bCount-aCount;\n\t\t});\n\t\tif(selectedCandidates[0].identifierWordIndices.some(index=>index>=0))return selectedCandidates[0].candidate;\n\t\treturn null;\n\t}\n\n\tdefaultParseSearchAreasResponse(searchAreasResponse:string){\n\t\tlet searchAreasResponseIndex=String(searchAreasResponse).indexOf('### Response:');\n\t\tif(searchAreasResponseIndex>=0)searchAreasResponseIndex+='### Response:'.length;\n\t\telse searchAreasResponseIndex=0;\n\t\treturn String(searchAreasResponse).substring(searchAreasResponseIndex).trim();\n\t}\n\n\tasync compareCandidates<Candidate>({\n\t\tcandidates,\n\t\tproblemDescription='',\n\t\tgenerateSearchAreasInstruction=this.defaultGenerateSearchAreasInstruction.bind(this),\n\t\tparseSearchAreasResponse=this.defaultParseSearchAreasResponse.bind(this),\n\t\tconvertCandidateToDocument=this.defaultConvertCandidateToDocument.bind(this),\n\t\tcandidatesForInitialSelection=2,\n\t\tcandidatesForFinalSelection=1,\n\t\tgenerateRankingInstruction=this.defaultGenerateRankingInstruction.bind(this),\n\t\textractIdentifiersFromRationale=this.defaultExtractIdentifiersFromRationale.bind(this),\n\t\textractIdentifierFromCandidateDocument=this.defaultExtractIdentifierFromCandidateDocument.bind(this),\n\t\tcandidateIdentifierField=undefined,\n\t\tfindCandidateFromIdentifier=this.defaultFindCandidateFromIdentifier.bind(this),\n\t\tgetSummarisableSubstringIndices,\n\t\tgeneratePromptTemplate=this.defaultGeneratePromptTemplate.bind(this),\n\t\tskipRationale=false\n\t}:AICompareCandidates.CompareArguments<Candidate>=<AICompareCandidates.CompareArguments<Candidate>>{}):Promise<AICompareCandidates.CompareCandidatesReturn<Candidate>|void>{\n\t\tif(!Array.isArray(candidates)||candidates.length<=0)throw new Error('No candidates provided');\n\t\tcandidatesForInitialSelection=lodash.toSafeInteger(candidatesForInitialSelection);\n\t\tif(candidatesForInitialSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tcandidatesForFinalSelection=lodash.toSafeInteger(candidatesForFinalSelection);\n\t\tif(candidatesForFinalSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tif(candidatesForInitialSelection<candidatesForFinalSelection)throw new Error('Candidates for initial selection must be equal or more than candidates for final selection');\n\t\tif(candidatesForInitialSelection>candidates.length)throw new Error('There are '+candidatesForInitialSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(candidatesForFinalSelection>candidates.length)throw new Error('There are '+candidatesForFinalSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(!candidateIdentifierField){\n\t\t\tcandidateIdentifierField=Object.keys(candidates[0] as object)[0] as keyof Candidate;\n\t\t\tif(!candidateIdentifierField)throw new Error('No candidate identifier field');\n\t\t}\n\n\t\tlet rationale='';\n\t\tlet selectedCandidates:Candidate[]=[];\n\n\t\tawait this.checkEmbedderLoaded();\n\t\tif(!this.embedder)return;\n\t\tlet candidateDocuments=candidates.map((candidate,index)=>convertCandidateToDocument({\n\t\t\tcandidate,\n\t\t\tindex\n\t\t}));\n\t\tlet vectorStore=await MemoryVectorStore.fromTexts(\n\t\t\tlodash.cloneDeep(candidateDocuments),\n\t\t\tcandidateDocuments.map((document,index)=>index),\n\t\t\tthis\n\t\t);\n\n\t\tlet searchAreasPromptTemplate=generatePromptTemplate(generateSearchAreasInstruction(problemDescription));\n\t\tif(this.DEBUG)console.log('Formatted search areas prompt: '+searchAreasPromptTemplate);\n\t\tawait this.checkTokeniserLoaded();\n\t\tif(!this.tokeniser)return;\n\t\tlet searchAreasPromptTokens=this.tokeniser.encode(searchAreasPromptTemplate);\n\t\tif(searchAreasPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Search areas instruction prompt is too long for the tokeniser model');\n\n\t\tawait this.checkGeneratorLoaded();\n\t\tif(!this.generator)return;\n\t\tlet pad_token_id=this.tokeniser.pad_token_id??this.tokeniser.sep_token_id??0;\n\t\tlet eos_token_id=this.tokeniser.sep_token_id??2;\n\t\tlet searchAreasReplyArray=await this.generator(searchAreasPromptTemplate,{\n\t\t\tmax_new_tokens:this.generateSearchAreasMaxNewTokens,\n\t\t\ttemperature:this.generateSearchAreasTemperature,\n\t\t\trepetition_penalty:this.generateSearchAreasRepetitionPenalty,\n\t\t\tpad_token_id,\n\t\t\teos_token_id\n\t\t});\n\t\tlet searchAreasReply=Array.isArray(searchAreasReplyArray?.[0])?searchAreasReplyArray?.[0]?.[0]:searchAreasReplyArray?.[0];\n\t\tif(!searchAreasReply.generated_text)throw new Error('No generated text for search areas');\n\t\tif(this.DEBUG)console.log('Generated search areas response: '+searchAreasReply.generated_text);\n\t\tlet vectorSearchQuery=parseSearchAreasResponse(Array.isArray(searchAreasReply.generated_text)?searchAreasReply.generated_text.join('\\n\\n'):String(searchAreasReply.generated_text));\n\t\t//generally the first sentence has the greatest relevance to the actual prompt\n\t\t//if(vectorSearchQuery.includes('.'))vectorSearchQuery=vectorSearchQuery.split('.')[0].trim();\n\t\tif(this.DEBUG)console.log('Vector search query: '+vectorSearchQuery);\n\t\tlet queryResult=await vectorStore.similaritySearch(vectorSearchQuery,candidatesForInitialSelection);\n\t\tif(this.DEBUG)console.log('Vector search results: ',queryResult);\n\n\t\tlet summaries:string[]=[];\n\t\t//only bother doing summarisation if there are candidates which exceed the token count\n\t\tif(queryResult.some(result=>result.pageContent.trim().split(/\\s+/).length>this.targetSummarisedStringTokenCount)){\n\t\t\tawait this.checkSummariserLoaded();\n\t\t\tif(!this.summariser)return;\n\t\t\tsummaries=(await Promise.allSettled(queryResult.map(async result=>{\n\t\t\t\tif(!result.pageContent||typeof result.pageContent!=='string')return '';\n\t\t\t\tif(result.pageContent.trim().split(/\\s+/).length<=this.targetSummarisedStringTokenCount)return result.pageContent;\n\t\t\t\tlet summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices={\n\t\t\t\t\tstart:0,\n\t\t\t\t\tend:result.pageContent.length\n\t\t\t\t};\n\t\t\t\tif(getSummarisableSubstringIndices)Object.assign(summarisableSubstringIndices,getSummarisableSubstringIndices(result.pageContent));\n\t\t\t\tsummarisableSubstringIndices.start=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.start),0,result.pageContent.length);\n\t\t\t\tsummarisableSubstringIndices.end=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.end),0,result.pageContent.length);\n\t\t\t\tif(this.DEBUG)console.log(summarisableSubstringIndices);\n\t\t\t\tlet summarisableSubstring=result.pageContent.substring(summarisableSubstringIndices.start,summarisableSubstringIndices.end);\n\t\t\t\tif(this.DEBUG)console.log(summarisableSubstring);\n\t\t\t\tlet contentBefore=result.pageContent.substring(0,summarisableSubstringIndices.start);\n\t\t\t\tlet contentAfter=result.pageContent.substring(summarisableSubstringIndices.end);\n\t\t\t\tlet wordsWithoutSummarisable=contentBefore.split(/s+/).length+contentAfter.split(/s+/).length;\n\t\t\t\tlet targetSummarisedSubstringTokenCount=Math.max(1,this.targetSummarisedStringTokenCount-wordsWithoutSummarisable);\n\t\t\t\tif(this.DEBUG)console.log(wordsWithoutSummarisable,targetSummarisedSubstringTokenCount);\n\t\t\t\tlet summarisedSubstringArray=await this.summariser?.(summarisableSubstring,<TextGenerationConfig>{\n\t\t\t\t\tmax_length:targetSummarisedSubstringTokenCount\n\t\t\t\t});\n\t\t\t\tlet summarisedSubstring=Array.isArray(summarisedSubstringArray?.[0])?summarisedSubstringArray?.[0]?.[0]:summarisedSubstringArray?.[0];\n\t\t\t\tif(this.DEBUG)console.log(summarisedSubstringArray,summarisedSubstring);\n\t\t\t\tlet summarisedString=contentBefore+(summarisedSubstring?.summary_text??'').split(/s+/).slice(targetSummarisedSubstringTokenCount).join(' ')+contentAfter;\n\t\t\t\tif(this.DEBUG)console.log('Summarised candidate: '+summarisedString);\n\t\t\t\treturn summarisedString;\n\t\t\t}))).filter(result=>result.status==='fulfilled'&&result.value).map(result=>(result as PromiseFulfilledResult<string>).value);\n\t\t}else{\n\t\t\tsummaries=queryResult.map(result=>result.pageContent);\n\t\t}\n\n\t\tif(!skipRationale){\n\t\t\tlet rankingPromptTemplate=generatePromptTemplate(generateRankingInstruction({\n\t\t\t\tproblemDescription,\n\t\t\t\tsummaries,\n\t\t\t\tcandidatesForFinalSelection,\n\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t}));\n\t\t\tif(this.DEBUG)console.log('Formatted ranking prompt: '+rankingPromptTemplate);\n\t\t\tlet rankingPromptTokens=this.tokeniser.encode(rankingPromptTemplate);\n\t\t\tif(rankingPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Ranking instruction prompt is too long for the tokeniser model');\n\t\t\ttry{\n\t\t\t\tlet rankingArray=await this.generator(rankingPromptTemplate,{\n\t\t\t\t\tmax_new_tokens:this.rankingMaxNewTokens,\n\t\t\t\t\ttemperature:this.rankingTemperature,\n\t\t\t\t\trepetition_penalty:this.rankingRepetitionPenalty,\n\t\t\t\t\tpad_token_id,\n\t\t\t\t\teos_token_id\n\t\t\t\t});\n\t\t\t\tlet ranking=Array.isArray(rankingArray?.[0])?rankingArray?.[0]?.[0]:rankingArray[0];\n\t\t\t\trationale=ranking.generated_text.toString().trim().replace(/(\\*\\*)|(<\\/?s>)|(\\[.*?\\])\\s*/g, '');\n\t\t\t\tif(this.DEBUG)console.log('Generated rationale: '+rationale);\n\t\t\t\tlet rationaleResponseIndex=rationale.indexOf('### Response:');\n\t\t\t\tif(rationaleResponseIndex>=0)rationaleResponseIndex+='### Response:'.length;\n\t\t\t\telse rationaleResponseIndex=0;\n\t\t\t\trationale=rationale.substring(rationaleResponseIndex);\n\t\t\t\t//if(!rationale)throw new Error('No rationale generated');\n\t\t\t}catch(error){\n\t\t\t\tconsole.log(error);\n\t\t\t\trationale='';\n\t\t\t}\n\t\t}\n\n\t\tif(rationale){\n\t\t\tlet identifiers=extractIdentifiersFromRationale(rationale);\n\t\t\tif(this.DEBUG)console.log('Extracted identifiers from rationale: '+identifiers);\n\t\t\tif(identifiers.length>candidatesForFinalSelection)identifiers=identifiers.slice(0,candidatesForFinalSelection);\n\t\t\tselectedCandidates=lodash.compact(identifiers.map(identifier=>findCandidateFromIdentifier({\n\t\t\t\tidentifier,\n\t\t\t\tcandidateIdentifierField,\n\t\t\t\tcandidates\n\t\t\t})));\n\t\t}\n\n\t\tif(!Array.isArray(selectedCandidates)||selectedCandidates.length<candidatesForFinalSelection){\n\t\t\tif(!Array.isArray(selectedCandidates))selectedCandidates=[];\n\t\t\tlet additionalSelectedCandidates=lodash.compact(queryResult.map(result=>{\n\t\t\t\tlet identifier=extractIdentifierFromCandidateDocument({\n\t\t\t\t\tcandidateDocument:result.pageContent,\n\t\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t\t});\n\t\t\t\tif(this.DEBUG)console.log('Extracted identifier from candidate document: '+identifier);\n\t\t\t\treturn findCandidateFromIdentifier({\n\t\t\t\t\tidentifier,\n\t\t\t\t\tcandidateIdentifierField,\n\t\t\t\t\tcandidates\n\t\t\t\t});\n\t\t\t}));\n\t\t\tselectedCandidates.splice(selectedCandidates.length,0,...additionalSelectedCandidates);\n\t\t\tselectedCandidates=lodash.uniq(selectedCandidates).slice(0,candidatesForFinalSelection-selectedCandidates.length);\n\t\t}\n\t\tif(this.DEBUG)console.log('Selected candidates',selectedCandidates);\n\n\t\treturn{\n\t\t\trationale,\n\t\t\tselectedCandidates\n\t\t};\n\t}\n};\n\nexport namespace AICompareCandidates{\n\texport interface LoadArguments{\n\t\tprogressCallback?:ProgressCallback;\n\t\tmodelName?:string;\n\t};\n\n\texport interface SummarisableSubstringIndices{\n\t\tstart:number;\n\t\tend:number;\n\t};\n\n\texport interface CompareArguments<Candidate>{\n\t\tcandidates:Candidate[];\n\t\tproblemDescription:string;\n\t\tgenerateSearchAreasInstruction?:(problemDescription:string)=>string;\n\t\tparseSearchAreasResponse?:(searchAreasResponse:string)=>string;\n\t\tconvertCandidateToDocument?:(convertCandidateToDocumentArguments:ConvertCandidateToDocumentArguments<Candidate>)=>string;\n\t\tcandidatesForInitialSelection?:number;\n\t\tcandidatesForFinalSelection?:number;\n\t\tgenerateRankingInstruction?:(generateRankingInstructionArguments:GenerateRankingInstructionArguments)=>string;\n\t\textractIdentifiersFromRationale?:(rationale:string)=>string[];\n\t\textractIdentifierFromCandidateDocument?:(extractIdentifierFromCandidateDocumentArguments:ExtractIdentifierFromCandidateDocumentArguments)=>string;\n\t\tcandidateIdentifierField?:keyof Candidate;\n\t\tfindCandidateFromIdentifier?:(findCandidateFromIdentifierArguments:FindCandidateFromIdentifierArguments<Candidate>)=>Candidate|null;\n\t\tgetSummarisableSubstringIndices?:(candidateDocument:string)=>SummarisableSubstringIndices;\n\t\tgeneratePromptTemplate?:(prompt:string)=>string;\n\t\tskipRationale?:boolean;\n\t};\n\n\texport interface ConvertCandidateToDocumentArguments<Candidate>{\n\t\tcandidate:Candidate;\n\t\tindex:number;\n\t};\n\n\texport interface ExtractIdentifierFromCandidateDocumentArguments{\n\t\tcandidateDocument:string;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface FindCandidateFromIdentifierArguments<Candidate>{\n\t\tidentifier:string;\n\t\tcandidateIdentifierField:keyof Candidate;\n\t\tcandidates:Candidate[];\n\t};\n\n\texport interface GenerateRankingInstructionArguments{\n\t\tproblemDescription:string;\n\t\tsummaries:string[];\n\t\tcandidatesForFinalSelection:number;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface CompareCandidatesReturn<Candidate>{\n\t\tselectedCandidates:Candidate[],\n\t\trationale:string\n\t};\n};\n\nexport default AICompareCandidates;"],"mappings":"itBAkBA,IAAa,EAAb,cAAyCA,EAAAA,UAAU,CAClD,IAAaC,EAAAA,IACb,MAAM,GAEN,UAAsC,KACtC,mBAAmB,yBACnB,iBAAsD,KACtD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE7B,WAAsC,KACtC,oBAAoB,6BACpB,kBAAsD,KACtD,uBAAkD,EAAE,CACpD,2BAAiD,KACjD,0BAA0B,IAAI,gBAE9B,SAAwC,KACxC,kBAAkB,2BAClB,gBAAwD,KACxD,qBAAgD,EAAE,CAClD,yBAA+C,KAC/C,wBAAwB,IAAI,gBAE5B,UAAmC,KACnC,mBAAmB,KAAK,mBACxB,iBAAmD,KACnD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE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O,EAAmB,OAAO,EAAE,GAAG,EAA6B,CACtF,EAAmB,EAAA,QAAO,KAAK,EAAmB,CAAC,MAAM,EAAE,EAA4B,EAAmB,OAAO,CAIlH,OAFG,KAAK,OAAM,QAAQ,IAAI,sBAAsB,EAAmB,CAE7D,CACL,YACA,qBACA,2BA8DH,IAAA,EAAe"}
package/dist/index.d.cts CHANGED
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;cAkBa,mBAAA,SAA4B,UAAA;gBAAR,iCAAA,CACpB;;EADA,SAAA,EAIF,sBAJsB,GAAA,IAAA;EAAA,kBAAA,EAAA,MAAA;EAItB,gBAAA,EAEO,OAFP,CAEe,sBAFf,CAAA,GAAA,IAAA;EAEe,qBAAA,EACH,YADG;EAAR,yBAAA,EAES,gBAFT,GAAA,IAAA;EACK,wBAAA,EAEE,eAFF;EACI,UAAA,EAGf,qBAHe,GAAA,IAAA;EACF,mBAAA,EAAA,MAAA;EAEb,iBAAA,EAEO,OAFP,CAEe,qBAFf,CAAA,GAAA,IAAA;EAEe,sBAAA,EACH,YADG;EAAR,0BAAA,EAES,gBAFT,GAAA,IAAA;EACK,yBAAA,EAEE,eAFF;EACI,QAAA,EAGlB,yBAHkB,GAAA,IAAA;EACF,iBAAA,EAAA,MAAA;EAEhB,eAAA,EAEO,OAFP,CAEe,yBAFf,CAAA,GAAA,IAAA;EAEe,oBAAA,EACH,YADG;EAAR,wBAAA,EAES,gBAFT,GAAA,IAAA;EACK,uBAAA,EAEE,eAFF;EACI,SAAA,EAGf,mBAHe,GAAA,IAAA;EACF,kBAAA,EAAA,MAAA;EAEb,gBAAA,EAEO,OAFP,CAEe,mBAFf,CAAA,GAAA,IAAA;EAEe,qBAAA,EACH,YADG;EAAR,yBAAA,EAES,gBAFT,GAAA,IAAA;EACK,wBAAA,EAEE,eAFF;EACI,+BAAA,EAAA,MAAA;EACF,8BAAA,EAAA,MAAA;EAu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AAA,MAAA;EACA;EACA,UAAA,oCAAA,CAAA,SAAA,CAAA,CAAA;IACA,UAAA,EAAA,MAAA;IACA,wBAAA,EAAA,MAoN+B,SApN/B;IACA,UAAA,EAoNW,SApNX,EAAA;EACA;EACA,UAAA,mCAAA,CAAA;IACA,kBAAA,EAAA,MAAA;IACA,SAAA,EAAA,MAAA,EAAA;IACA,2BAAA,EAAA,MAAA;IACA,wBAAA,EAAA,MAAA;EACA;EACsC,UAAA,uBAAA,CAAA,SAAA,CAAA,CAAA;IAArC,kBAAoB,EAuNF,SAvNE,EAAA;IAAqI,SAAA,EAAA,MAAA;EAA5C"}
package/dist/index.d.mts CHANGED
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;cAkBa,mBAAA,SAA4B,UAAA;gBAAR,iCAAA,CACpB;;EADA,SAAA,EAIF,sBAJsB,GAAA,IAAA;EAAA,kBAAA,EAAA,MAAA;EAItB,gBAAA,EAEO,OAFP,CAEe,sBAFf,CAAA,GAAA,IAAA;EAEe,qBAAA,EACH,YADG;EAAR,yBAAA,EAES,gBAFT,GAAA,IAAA;EACK,wBAAA,EAEE,eAFF;EACI,UAAA,EAGf,qBAHe,GAAA,IAAA;EACF,mBAAA,EAAA,MAAA;EAEb,iBAAA,EAEO,OAFP,CAEe,qBAFf,CAAA,GAAA,IAAA;EAEe,sBAAA,EACH,YADG;EAAR,0BAAA,EAES,gBAFT,GAAA,IAAA;EACK,yBAAA,EAEE,eAFF;EACI,QAAA,EAGlB,yBAHkB,GAAA,IAAA;EACF,iBAAA,EAAA,MAAA;EAEhB,eAAA,EAEO,OAFP,CAEe,yBAFf,CAAA,GAAA,IAAA;EAEe,oBAAA,EACH,YADG;EAAR,wBAAA,EAES,gBAFT,GAAA,IAAA;EACK,uBAAA,EAEE,eAFF;EACI,SAAA,EAGf,mBAHe,GAAA,IAAA;EACF,kBAAA,EAAA,MAAA;EAEb,gBAAA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AAA;EACA;EACA,UAAA,mCAAA,CAAA,SAAA,CAAA,CAAA;IAC0D,SAAA,EA4PhD,SA5PgD;IAAzD,KAAA,EAAA,MAAoB;EAAuH;EA6C5I,UAAA,+CAAA,CAAA;IACA,iBAAA,EAAA,MAAA;IACA,wBAAA,EAAA,MAAA;EACA;EACA,UAAA,oCAAA,CAAA,SAAA,CAAA,CAAA;IACA,UAAA,EAAA,MAAA;IACA,wBAAA,EAAA,MAoN+B,SApN/B;IACA,UAAA,EAoNW,SApNX,EAAA;EACA;EACA,UAAA,mCAAA,CAAA;IACA,kBAAA,EAAA,MAAA;IACA,SAAA,EAAA,MAAA,EAAA;IACA,2BAAA,EAAA,MAAA;IACA,wBAAA,EAAA,MAAA;EACA;EACsC,UAAA,uBAAA,CAAA,SAAA,CAAA,CAAA;IAArC,kBAAoB,EAuNF,SAvNE,EAAA;IAAqI,SAAA,EAAA,MAAA;EAA5C"}
package/dist/index.mjs CHANGED
@@ -22,5 +22,5 @@ Format exactly:
22
22
  #2. ...`}regexIndexOf(e,t,n){let r=e.slice(n).search(t);return r<0?r:r+n}defaultExtractIdentifierFromCandidateDocument({candidateDocument:e,candidateIdentifierField:t}={}){this.DEBUG&&console.log(e,t);let n=a.startCase(t),r=e.indexOf(n);if(r<0&&(r=e.toLowerCase().indexOf(n.toLowerCase())),this.DEBUG&&console.log(r),r>=0&&(r+=n.length),r<0&&(r=e.toLowerCase().indexOf(t.toLowerCase()),r>=0&&(r+=t.length)),this.DEBUG)console.log(r);else return``;if(r=e.indexOf(`:`,r),this.DEBUG&&console.log(r),r<0&&(r=this.regexIndexOf(e,/\s+/,r)),this.DEBUG&&console.log(r),r<0)return``;let i=e.indexOf(`
23
23
  `,r);return i<0&&(i=e.length),this.DEBUG&&console.log(i),e.substring(r,i).trim()}defaultExtractIdentifiersFromRationale(e){let t=/^\s*#\s*\d+\s*\.?\s*"([^"]+)"/gm,n=[];for(let r;Array.isArray(r=t.exec(e));)r[1]&&n.push(r[1]);return n}defaultFindCandidateFromIdentifier({identifier:e,candidateIdentifierField:t,candidates:n}={}){let r=n.find(n=>String(n[t]).toLowerCase()===e.toLowerCase());if(r||(r=n.find(n=>String(n[t]).toLowerCase().includes(e.toLowerCase())),r)||(r=n.find(n=>e.toLowerCase().includes(String(n[t]).toLowerCase())),r))return r;let i=e.split(/\s+/g),o=n.map(e=>({identifierWordIndices:i.map(n=>String(e[t]).indexOf(n)),candidate:e})).sort((e,t)=>{let n=a.sumBy(e.identifierWordIndices,e=>e<0?0:1),r=a.sumBy(t.identifierWordIndices,e=>e<0?0:1);if(n!==r)return r-n;if(n===0&&r===0)return 0;n=0,r=0;for(let t=0;t<e.identifierWordIndices.length-1;++t)for(let r=t+1;r<e.identifierWordIndices.length;++r)e.identifierWordIndices[t]<0||e.identifierWordIndices[r]<0||e.identifierWordIndices[t]<e.identifierWordIndices[r]&&++n;for(let e=0;e<t.identifierWordIndices.length-1;++e)for(let n=e+1;n<t.identifierWordIndices.length;++n)t.identifierWordIndices[e]<0||t.identifierWordIndices[n]<0||t.identifierWordIndices[e]<t.identifierWordIndices[n]&&++r;return r-n});return o[0].identifierWordIndices.some(e=>e>=0)?o[0].candidate:null}defaultParseSearchAreasResponse(e){let t=String(e).indexOf(`### Response:`);return t>=0?t+=13:t=0,String(e).substring(t).trim()}async compareCandidates({candidates:e,problemDescription:t=``,generateSearchAreasInstruction:n=this.defaultGenerateSearchAreasInstruction.bind(this),parseSearchAreasResponse:i=this.defaultParseSearchAreasResponse.bind(this),convertCandidateToDocument:o=this.defaultConvertCandidateToDocument.bind(this),candidatesForInitialSelection:s=2,candidatesForFinalSelection:c=1,generateRankingInstruction:l=this.defaultGenerateRankingInstruction.bind(this),extractIdentifiersFromRationale:u=this.defaultExtractIdentifiersFromRationale.bind(this),extractIdentifierFromCandidateDocument:d=this.defaultExtractIdentifierFromCandidateDocument.bind(this),candidateIdentifierField:f=void 0,findCandidateFromIdentifier:p=this.defaultFindCandidateFromIdentifier.bind(this),getSummarisableSubstringIndices:m,generatePromptTemplate:h=this.defaultGeneratePromptTemplate.bind(this),skipRationale:g=!1}={}){if(!Array.isArray(e)||e.length<=0)throw Error(`No candidates provided`);if(s=a.toSafeInteger(s),s<=0||(c=a.toSafeInteger(c),c<=0))throw Error(`Candidates for initial selection must be a positive integer bigger than 0`);if(s<c)throw Error(`Candidates for initial selection must be equal or more than candidates for final selection`);if(s>e.length)throw Error(`There are `+s+`candidates for initial selection which is more than the total number of candidates of `+e.length);if(c>e.length)throw Error(`There are `+c+`candidates for initial selection which is more than the total number of candidates of `+e.length);if(!f&&(f=Object.keys(e[0])[0],!f))throw Error(`No candidate identifier field`);let _=``,v=[];if(await this.checkEmbedderLoaded(),!this.embedder)return;let y=e.map((e,t)=>o({candidate:e,index:t})),b=await r.fromTexts(a.cloneDeep(y),y.map((e,t)=>t),this),x=h(n(t));if(this.DEBUG&&console.log(`Formatted search areas prompt: `+x),await this.checkTokeniserLoaded(),!this.tokeniser)return;if(this.tokeniser.encode(x).length>this.tokeniser.model_max_length)throw Error(`Search areas instruction prompt is too long for the tokeniser model`);if(await this.checkGeneratorLoaded(),!this.generator)return;let S=this.tokeniser.pad_token_id??this.tokeniser.sep_token_id??0,C=this.tokeniser.sep_token_id??2,w=await this.generator(x,{max_new_tokens:this.generateSearchAreasMaxNewTokens,temperature:this.generateSearchAreasTemperature,repetition_penalty:this.generateSearchAreasRepetitionPenalty,pad_token_id:S,eos_token_id:C}),T=Array.isArray(w?.[0])?w?.[0]?.[0]:w?.[0];if(!T.generated_text)throw Error(`No generated text for search areas`);this.DEBUG&&console.log(`Generated search areas response: `+T.generated_text);let E=i(Array.isArray(T.generated_text)?T.generated_text.join(`
24
24
 
25
- `):String(T.generated_text));this.DEBUG&&console.log(`Vector search query: `+E);let D=await b.similaritySearch(E,s);this.DEBUG&&console.log(`Vector search results: `,D);let O=[];if(D.some(e=>e.pageContent.trim().split(/\s+/).length>this.targetSummarisedStringTokenCount)){if(await this.checkSummariserLoaded(),!this.summariser)return;O=(await Promise.allSettled(D.map(async e=>{if(!e.pageContent||typeof e.pageContent!=`string`)return``;if(e.pageContent.trim().split(/\s+/).length<=this.targetSummarisedStringTokenCount)return e.pageContent;let t={start:0,end:e.pageContent.length};m&&Object.assign(t,m(e.pageContent)),t.start=a.clamp(a.toSafeInteger(t.start),0,e.pageContent.length),t.end=a.clamp(a.toSafeInteger(t.end),0,e.pageContent.length);let n=e.pageContent.substring(t.start,t.end),r=e.pageContent.substring(0,t.start),i=e.pageContent.substring(t.end),o=r.split(/s+/).length+i.split(/s+/).length,s=Math.max(1,this.targetSummarisedStringTokenCount-o),c=await this.summariser?.(n,{max_length:s}),l=r+((Array.isArray(c?.[0])?c?.[0]?.[0]:c?.[0])?.summary_text??``).split(/s+/).slice(s).join(` `)+i;return this.DEBUG&&console.log(`Summarised candidate: `+l),l}))).filter(e=>e.status===`fulfilled`&&e.value).map(e=>e.value)}else O=D.map(e=>e.pageContent);if(!g){let e=h(l({problemDescription:t,summaries:O,candidatesForFinalSelection:c,candidateIdentifierField:String(f)}));if(this.DEBUG&&console.log(`Formatted ranking prompt: `+e),this.tokeniser.encode(e).length>this.tokeniser.model_max_length)throw Error(`Ranking instruction prompt is too long for the tokeniser model`);try{let t=await this.generator(e,{max_new_tokens:this.rankingMaxNewTokens,temperature:this.rankingTemperature,repetition_penalty:this.rankingRepetitionPenalty,pad_token_id:S,eos_token_id:C});_=(Array.isArray(t?.[0])?t?.[0]?.[0]:t[0]).generated_text.toString().trim().replace(/(\*\*)|(<\/?s>)|(\[.*?\])\s*/g,``),this.DEBUG&&console.log(`Generated rationale: `+_);let n=_.indexOf(`### Response:`);n>=0?n+=13:n=0,_=_.substring(n)}catch(e){console.log(e),_=``}}if(_){let t=u(_);this.DEBUG&&console.log(`Extracted identifiers from rationale: `+t),t.length>c&&(t=t.slice(0,c)),v=a.compact(t.map(t=>p({identifier:t,candidateIdentifierField:f,candidates:e})))}if(!Array.isArray(v)||v.length<c){Array.isArray(v)||(v=[]);let t=a.compact(D.map(t=>{let n=d({candidateDocument:t.pageContent,candidateIdentifierField:String(f)});return this.DEBUG&&console.log(`Extracted identifier from candidate document: `+n),p({identifier:n,candidateIdentifierField:f,candidates:e})}));v.splice(v.length,0,...t),v=a.uniq(v).slice(0,c-v.length)}return this.DEBUG&&console.log(`Selected candidates`,v),{rationale:_,selectedCandidates:v}}};(function(e){})(s||={});var c=s;export{s as AICompareCandidates,c as default};
25
+ `):String(T.generated_text));this.DEBUG&&console.log(`Vector search query: `+E);let D=await b.similaritySearch(E,s);this.DEBUG&&console.log(`Vector search results: `,D);let O=[];if(D.some(e=>e.pageContent.trim().split(/\s+/).length>this.targetSummarisedStringTokenCount)){if(await this.checkSummariserLoaded(),!this.summariser)return;O=(await Promise.allSettled(D.map(async e=>{if(!e.pageContent||typeof e.pageContent!=`string`)return``;if(e.pageContent.trim().split(/\s+/).length<=this.targetSummarisedStringTokenCount)return e.pageContent;let t={start:0,end:e.pageContent.length};m&&Object.assign(t,m(e.pageContent)),t.start=a.clamp(a.toSafeInteger(t.start),0,e.pageContent.length),t.end=a.clamp(a.toSafeInteger(t.end),0,e.pageContent.length),this.DEBUG&&console.log(t);let n=e.pageContent.substring(t.start,t.end);this.DEBUG&&console.log(n);let r=e.pageContent.substring(0,t.start),i=e.pageContent.substring(t.end),o=r.split(/s+/).length+i.split(/s+/).length,s=Math.max(1,this.targetSummarisedStringTokenCount-o);this.DEBUG&&console.log(o,s);let c=await this.summariser?.(n,{max_length:s}),l=Array.isArray(c?.[0])?c?.[0]?.[0]:c?.[0];this.DEBUG&&console.log(c,l);let u=r+(l?.summary_text??``).split(/s+/).slice(s).join(` `)+i;return this.DEBUG&&console.log(`Summarised candidate: `+u),u}))).filter(e=>e.status===`fulfilled`&&e.value).map(e=>e.value)}else O=D.map(e=>e.pageContent);if(!g){let e=h(l({problemDescription:t,summaries:O,candidatesForFinalSelection:c,candidateIdentifierField:String(f)}));if(this.DEBUG&&console.log(`Formatted ranking prompt: `+e),this.tokeniser.encode(e).length>this.tokeniser.model_max_length)throw Error(`Ranking instruction prompt is too long for the tokeniser model`);try{let t=await this.generator(e,{max_new_tokens:this.rankingMaxNewTokens,temperature:this.rankingTemperature,repetition_penalty:this.rankingRepetitionPenalty,pad_token_id:S,eos_token_id:C});_=(Array.isArray(t?.[0])?t?.[0]?.[0]:t[0]).generated_text.toString().trim().replace(/(\*\*)|(<\/?s>)|(\[.*?\])\s*/g,``),this.DEBUG&&console.log(`Generated rationale: `+_);let n=_.indexOf(`### Response:`);n>=0?n+=13:n=0,_=_.substring(n)}catch(e){console.log(e),_=``}}if(_){let t=u(_);this.DEBUG&&console.log(`Extracted identifiers from rationale: `+t),t.length>c&&(t=t.slice(0,c)),v=a.compact(t.map(t=>p({identifier:t,candidateIdentifierField:f,candidates:e})))}if(!Array.isArray(v)||v.length<c){Array.isArray(v)||(v=[]);let t=a.compact(D.map(t=>{let n=d({candidateDocument:t.pageContent,candidateIdentifierField:String(f)});return this.DEBUG&&console.log(`Extracted identifier from candidate document: `+n),p({identifier:n,candidateIdentifierField:f,candidates:e})}));v.splice(v.length,0,...t),v=a.uniq(v).slice(0,c-v.length)}return this.DEBUG&&console.log(`Selected candidates`,v),{rationale:_,selectedCandidates:v}}};(function(e){})(s||={});var c=s;export{s as AICompareCandidates,c as default};
26
26
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["matches:string[]","match:RegExpExecArray|null","selectedCandidates:Candidate[]","summaries:string[]","summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices"],"sources":["../src/index.ts"],"sourcesContent":["import{\n\tenv,\n\tpipeline,\n\tAutoTokenizer,\n\tTextGenerationPipeline,\n\tProgressInfo,\n\tProgressCallback,\n\tSummarizationPipeline,\n\tFeatureExtractionPipeline,\n\tPreTrainedTokenizer,\n\tTextGenerationConfig,\n\tTextGenerationSingle\n}from '@sroussey/transformers';\nimport {MemoryVectorStore} from '@langchain/classic/vectorstores/memory';\nimport {Embeddings} from '@langchain/core/embeddings';\nimport lodash from 'lodash';\nimport jsan from 'jsan';\n\nexport class AICompareCandidates extends Embeddings{\n\treadonly env=env;\n\tDEBUG=true;\n\n\tgenerator:TextGenerationPipeline|null=null;\n\tgeneratorModelName='Xenova/LaMini-GPT-774M';\n\tgeneratorPromise:Promise<TextGenerationPipeline>|null=null;\n\tgeneratorProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tgeneratorProgressCallback:ProgressCallback|null=null;\n\tgeneratorAbortController=new AbortController();\n\n\tsummariser:SummarizationPipeline|null=null;\n\tsummariserModelName='Xenova/distilbart-cnn-12-6';\n\tsummariserPromise:Promise<SummarizationPipeline>|null=null;\n\tsummariserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tsummariserProgressCallback:ProgressCallback|null=null;\n\tsummariserAbortController=new AbortController();\n\n\tembedder:FeatureExtractionPipeline|null=null;\n\tembedderModelName='Xenova/all-MiniLM-L12-v2';\n\tembedderPromise:Promise<FeatureExtractionPipeline>|null=null;\n\tembedderProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tembedderProgressCallback:ProgressCallback|null=null;\n\tembedderAbortController=new AbortController();\n\n\ttokeniser:PreTrainedTokenizer|null=null;\n\ttokeniserModelName=this.generatorModelName;\n\ttokeniserPromise:Promise<PreTrainedTokenizer>|null=null;\n\ttokeniserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\ttokeniserProgressCallback:ProgressCallback|null=null;\n\ttokeniserAbortController=new AbortController();\n\n\tgenerateSearchAreasMaxNewTokens=64;\n\tgenerateSearchAreasTemperature=0.35;\n\tgenerateSearchAreasRepetitionPenalty=1.5;\n\n\trankingMaxNewTokens=64;\n\trankingTemperature=0.35;\n\trankingRepetitionPenalty=1.5;\n\n\ttargetSummarisedStringTokenCount=420;\n\n\tstatic{\n\t\tenv.localModelPath='';\n\t\tenv.allowRemoteModels=true;\n\t\tenv.allowLocalModels=false;\n\t}\n\n\tconstructor(){\n\t\tsuper({});\n\t}\n\t\n\tasync loadGenerator({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.generatorModelName=modelName;\n\t\tif(!this.generatorModelName)throw new Error('Invalid generator model name');\n\t\tif(progressCallback)this.generatorProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.generatorPromise=pipeline('text-generation',this.generatorModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.generatorProgressInfo,progressInfo);\n\t\t\t\treturn this.generatorProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.generatorAbortController.signal\n\t\t});\n\t\tthis.generator=await this.generatorPromise;\n\t\treturn this.generator;\n\t}\n\n\tasync checkGeneratorLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.generatorPromise)this.loadGenerator({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.generator){\n\t\t\ttry{\n\t\t\t\tawait this.generatorPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.generatorPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.generator){\n\t\t\tthis.generatorPromise=null;\n\t\t\tthrow new Error('Unable to load generator');\n\t\t}\n\t}\n\n\tasync abortLoadGenerator(reason?:any){\n\t\tthis.generatorAbortController.abort(reason);\n\t\tthis.generatorAbortController=new AbortController();\n\t}\n\n\tasync loadSummariser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.summariserModelName=modelName;\n\t\tif(!this.summariserModelName)throw new Error('Invalid summariser model name');\n\t\tif(progressCallback)this.summariserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.summariserPromise=pipeline('summarization',this.summariserModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.summariserProgressInfo,progressInfo);\n\t\t\t\treturn this.summariserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.summariserAbortController.signal\n\t\t});\n\t\tthis.summariser=await this.summariserPromise;\n\t\treturn this.summariser;\n\t}\n\n\tasync checkSummariserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.summariserPromise)this.loadSummariser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.summariser){\n\t\t\ttry{\n\t\t\t\tawait this.summariserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.summariserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.summariser){\n\t\t\tthis.summariserPromise=null;\n\t\t\tthrow new Error('Unable to load summariser');\n\t\t}\n\t}\n\n\tasync abortLoadSummariser(){\n\t\tthis.summariserAbortController.abort();\n\t\tthis.summariserAbortController=new AbortController();\n\t}\n\n\tasync loadEmbedder({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.embedderModelName=modelName;\n\t\tif(!this.embedderModelName)throw new Error('Invalid embedder model name');\n\t\tif(progressCallback)this.embedderProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.embedderPromise=pipeline('feature-extraction',this.embedderModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.embedderProgressInfo,progressInfo);\n\t\t\t\treturn this.embedderProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.embedderAbortController.signal\n\t\t});\n\t\tthis.embedder=await this.embedderPromise;\n\t\treturn this.embedder;\n\t}\n\n\tasync checkEmbedderLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.embedderPromise)this.loadEmbedder({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.embedder){\n\t\t\ttry{\n\t\t\t\tawait this.embedderPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.embedderPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.embedder){\n\t\t\tthis.embedderPromise=null;\n\t\t\tthrow new Error('Unable to load embedder');\n\t\t}\n\t}\n\n\tasync abortLoadEmbedder(){\n\t\tthis.embedderAbortController.abort();\n\t\tthis.embedderAbortController=new AbortController();\n\t}\n\n\tasync loadTokeniser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.tokeniserModelName=modelName;\n\t\tif(!this.tokeniserModelName)throw new Error('Invalid tokeniser model name');\n\t\tif(progressCallback)this.tokeniserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.tokeniserPromise=AutoTokenizer.from_pretrained(this.tokeniserModelName,{\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.tokeniserProgressInfo,progressInfo);\n\t\t\t\treturn this.tokeniserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.tokeniserAbortController.signal\n\t\t});\n\t\tthis.tokeniser=await this.tokeniserPromise;\n\t\treturn this.tokeniser;\n\t}\n\n\tasync checkTokeniserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.tokeniserPromise)this.loadTokeniser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.tokeniser){\n\t\t\ttry{\n\t\t\t\tawait this.tokeniserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.tokeniserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.tokeniser){\n\t\t\tthis.tokeniserPromise=null;\n\t\t\tthrow new Error('Unable to load tokeniser');\n\t\t}\n\t}\n\n\tasync abortLoadTokeniser(){\n\t\tthis.tokeniserAbortController.abort();\n\t\tthis.tokeniserAbortController=new AbortController();\n\t}\n\n\tasync embedQuery(text:string):Promise<number[]>{\n\t\tawait this.checkEmbedderLoaded();\n\t\treturn Array.from((await this.embedder?.(text,{\n\t\t\tpooling:'mean',\n\t\t\tnormalize:true\n\t\t}))?.data);\n\t}\n\n\tasync embedDocuments(texts:string[]):Promise<number[][]>{\n\t\treturn Promise.all(texts.map(text=>this.embedQuery(text)));\n\t}\n\n\tdefaultGeneratePromptTemplate(prompt:string){\n\t\treturn 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n'+\n\t\t\t'### Instruction:\\n'+\n\t\t\tprompt+\n\t\t\t'\\n\\n### Response:';\n\t}\n\n\tdefaultGenerateSearchAreasInstruction(problemDescription:string){\n\t\treturn 'List the relevant subject areas for the following issues. Limit your response to 100 words.\\nIssues: \"'+problemDescription+'\"';\n\t}\n\n\tdefaultConvertCandidateToDocument<Candidate>({\n\t\tcandidate,\n\t\tindex\n\t}:AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>=<AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>>{}){\n\t\tlet document='Start of Candidate #'+index;\n\t\tfor(let i in candidate)document+='\\n'+lodash.startCase(i)+': '+(typeof candidate[i]==='object'?jsan.stringify(candidate[i]):String(candidate[i]));\n\t\tdocument+='\\nEnd of Candidate #'+index;\n\t\treturn document;\n\t}\n\n\tdefaultGenerateRankingInstruction({\n\t\tproblemDescription,\n\t\tsummaries,\n\t\tcandidatesForFinalSelection,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.GenerateRankingInstructionArguments=<AICompareCandidates.GenerateRankingInstructionArguments>{}){\n\t\treturn 'Strictly follow these rules:\\n'+\n\t\t\t'1. Rank ONLY the top '+candidatesForFinalSelection+' candidates with one 15-word sentence explaining why\\n'+\n\t\t\t'2. Rank the candidates based on \"'+problemDescription.replace(/(\\r|\\n)/g,' ')+'\"\\n'+\n\t\t\t'3. If unclear, say \"Insufficient information to determine\"\\n\\n'+\n\t\t\t'Candidates:\\n\\n'+summaries.join('\\n\\n')+'\\n\\n'+\n\t\t\t'Format exactly:\\n'+\n\t\t\t'#1. \"Full '+lodash.startCase(candidateIdentifierField)+'\": 15-word explanation\\n'+\n\t\t\t'#2. ...';\n\t}\n\n\tregexIndexOf(text:string,regex:RegExp,startIndex:number){\n \tlet indexInSuffix=text.slice(startIndex).search(regex);\n \treturn indexInSuffix<0?indexInSuffix:indexInSuffix+startIndex;\n\t}\n\n\tdefaultExtractIdentifierFromCandidateDocument({\n\t\tcandidateDocument,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments=<AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments>{}){\n\t\tif(this.DEBUG)console.log(candidateDocument,candidateIdentifierField);\n\t\tlet startCase=lodash.startCase(candidateIdentifierField);\n\t\tlet startIndex=candidateDocument.indexOf(startCase);\n\t\tif(startIndex<0)startIndex=candidateDocument.toLowerCase().indexOf(startCase.toLowerCase());\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex>=0)startIndex+=startCase.length;\n\t\tif(startIndex<0){\n\t\t\tstartIndex=candidateDocument.toLowerCase().indexOf(candidateIdentifierField.toLowerCase());\n\t\t\tif(startIndex>=0)startIndex+=candidateIdentifierField.length;\n\t\t}\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\telse return '';\n\t\tstartIndex=candidateDocument.indexOf(':',startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)startIndex=this.regexIndexOf(candidateDocument,/\\s+/,startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)return '';\n\t\tlet endIndex=candidateDocument.indexOf('\\n',startIndex);\n\t\tif(endIndex<0)endIndex=candidateDocument.length;\n\t\tif(this.DEBUG)console.log(endIndex);\n\t\treturn candidateDocument.substring(startIndex,endIndex).trim();\n\t}\n\n\tdefaultExtractIdentifiersFromRationale(rationale:string){\n\t\tlet regex=/^\\s*#\\s*\\d+\\s*\\.?\\s*\"([^\"]+)\"/gm;\n\t\tlet matches:string[]=[];\n\t\tfor(let match:RegExpExecArray|null;Array.isArray(match=regex.exec(rationale));)if(match[1])matches.push(match[1]);\n\t\treturn matches;\n\t}\n\n\tdefaultFindCandidateFromIdentifier<Candidate>({\n\t\tidentifier,\n\t\tcandidateIdentifierField,\n\t\tcandidates\n\t}:AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>=<AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>>{}){\n\t\tlet selectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase()===identifier.toLowerCase());\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase().includes(identifier.toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>identifier.toLowerCase().includes(String(candidate[candidateIdentifierField]).toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\t//split by space and find highest number of matches (tie break if it is in same order)\n\t\tlet identifierWords=identifier.split(/\\s+/g);\n\t\tlet selectedCandidates=candidates.map(candidate=>({\n\t\t\tidentifierWordIndices:identifierWords.map(identifierWord=>String(candidate[candidateIdentifierField]).indexOf(identifierWord)),\n\t\t\tcandidate\n\t\t})).sort((a,b)=>{\n\t\t\tlet aCount=lodash.sumBy(a.identifierWordIndices,aElement=>aElement<0?0:1);\n\t\t\tlet bCount=lodash.sumBy(b.identifierWordIndices,bElement=>bElement<0?0:1);\n\t\t\tif(aCount!==bCount)return bCount-aCount;\n\t\t\tif(aCount===0&&bCount===0)return 0;\n\t\t\taCount=0;\n\t\t\tbCount=0;\n\t\t\tfor(let i=0;i<a.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<a.identifierWordIndices.length;++j){\n\t\t\t\t\tif(a.identifierWordIndices[i]<0||a.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(a.identifierWordIndices[i]<a.identifierWordIndices[j])++aCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(let i=0;i<b.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<b.identifierWordIndices.length;++j){\n\t\t\t\t\tif(b.identifierWordIndices[i]<0||b.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(b.identifierWordIndices[i]<b.identifierWordIndices[j])++bCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bCount-aCount;\n\t\t});\n\t\tif(selectedCandidates[0].identifierWordIndices.some(index=>index>=0))return selectedCandidates[0].candidate;\n\t\treturn null;\n\t}\n\n\tdefaultParseSearchAreasResponse(searchAreasResponse:string){\n\t\tlet searchAreasResponseIndex=String(searchAreasResponse).indexOf('### Response:');\n\t\tif(searchAreasResponseIndex>=0)searchAreasResponseIndex+='### Response:'.length;\n\t\telse searchAreasResponseIndex=0;\n\t\treturn String(searchAreasResponse).substring(searchAreasResponseIndex).trim();\n\t}\n\n\tasync compareCandidates<Candidate>({\n\t\tcandidates,\n\t\tproblemDescription='',\n\t\tgenerateSearchAreasInstruction=this.defaultGenerateSearchAreasInstruction.bind(this),\n\t\tparseSearchAreasResponse=this.defaultParseSearchAreasResponse.bind(this),\n\t\tconvertCandidateToDocument=this.defaultConvertCandidateToDocument.bind(this),\n\t\tcandidatesForInitialSelection=2,\n\t\tcandidatesForFinalSelection=1,\n\t\tgenerateRankingInstruction=this.defaultGenerateRankingInstruction.bind(this),\n\t\textractIdentifiersFromRationale=this.defaultExtractIdentifiersFromRationale.bind(this),\n\t\textractIdentifierFromCandidateDocument=this.defaultExtractIdentifierFromCandidateDocument.bind(this),\n\t\tcandidateIdentifierField=undefined,\n\t\tfindCandidateFromIdentifier=this.defaultFindCandidateFromIdentifier.bind(this),\n\t\tgetSummarisableSubstringIndices,\n\t\tgeneratePromptTemplate=this.defaultGeneratePromptTemplate.bind(this),\n\t\tskipRationale=false\n\t}:AICompareCandidates.CompareArguments<Candidate>=<AICompareCandidates.CompareArguments<Candidate>>{}):Promise<AICompareCandidates.CompareCandidatesReturn<Candidate>|void>{\n\t\tif(!Array.isArray(candidates)||candidates.length<=0)throw new Error('No candidates provided');\n\t\tcandidatesForInitialSelection=lodash.toSafeInteger(candidatesForInitialSelection);\n\t\tif(candidatesForInitialSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tcandidatesForFinalSelection=lodash.toSafeInteger(candidatesForFinalSelection);\n\t\tif(candidatesForFinalSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tif(candidatesForInitialSelection<candidatesForFinalSelection)throw new Error('Candidates for initial selection must be equal or more than candidates for final selection');\n\t\tif(candidatesForInitialSelection>candidates.length)throw new Error('There are '+candidatesForInitialSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(candidatesForFinalSelection>candidates.length)throw new Error('There are '+candidatesForFinalSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(!candidateIdentifierField){\n\t\t\tcandidateIdentifierField=Object.keys(candidates[0] as object)[0] as keyof Candidate;\n\t\t\tif(!candidateIdentifierField)throw new Error('No candidate identifier field');\n\t\t}\n\n\t\tlet rationale='';\n\t\tlet selectedCandidates:Candidate[]=[];\n\n\t\tawait this.checkEmbedderLoaded();\n\t\tif(!this.embedder)return;\n\t\tlet candidateDocuments=candidates.map((candidate,index)=>convertCandidateToDocument({\n\t\t\tcandidate,\n\t\t\tindex\n\t\t}));\n\t\tlet vectorStore=await MemoryVectorStore.fromTexts(\n\t\t\tlodash.cloneDeep(candidateDocuments),\n\t\t\tcandidateDocuments.map((document,index)=>index),\n\t\t\tthis\n\t\t);\n\n\t\tlet searchAreasPromptTemplate=generatePromptTemplate(generateSearchAreasInstruction(problemDescription));\n\t\tif(this.DEBUG)console.log('Formatted search areas prompt: '+searchAreasPromptTemplate);\n\t\tawait this.checkTokeniserLoaded();\n\t\tif(!this.tokeniser)return;\n\t\tlet searchAreasPromptTokens=this.tokeniser.encode(searchAreasPromptTemplate);\n\t\tif(searchAreasPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Search areas instruction prompt is too long for the tokeniser model');\n\n\t\tawait this.checkGeneratorLoaded();\n\t\tif(!this.generator)return;\n\t\tlet pad_token_id=this.tokeniser.pad_token_id??this.tokeniser.sep_token_id??0;\n\t\tlet eos_token_id=this.tokeniser.sep_token_id??2;\n\t\tlet searchAreasReplyArray=await this.generator(searchAreasPromptTemplate,{\n\t\t\tmax_new_tokens:this.generateSearchAreasMaxNewTokens,\n\t\t\ttemperature:this.generateSearchAreasTemperature,\n\t\t\trepetition_penalty:this.generateSearchAreasRepetitionPenalty,\n\t\t\tpad_token_id,\n\t\t\teos_token_id\n\t\t});\n\t\tlet searchAreasReply=Array.isArray(searchAreasReplyArray?.[0])?searchAreasReplyArray?.[0]?.[0]:searchAreasReplyArray?.[0];\n\t\tif(!searchAreasReply.generated_text)throw new Error('No generated text for search areas');\n\t\tif(this.DEBUG)console.log('Generated search areas response: '+searchAreasReply.generated_text);\n\t\tlet vectorSearchQuery=parseSearchAreasResponse(Array.isArray(searchAreasReply.generated_text)?searchAreasReply.generated_text.join('\\n\\n'):String(searchAreasReply.generated_text));\n\t\t//generally the first sentence has the greatest relevance to the actual prompt\n\t\t//if(vectorSearchQuery.includes('.'))vectorSearchQuery=vectorSearchQuery.split('.')[0].trim();\n\t\tif(this.DEBUG)console.log('Vector search query: '+vectorSearchQuery);\n\t\tlet queryResult=await vectorStore.similaritySearch(vectorSearchQuery,candidatesForInitialSelection);\n\t\tif(this.DEBUG)console.log('Vector search results: ',queryResult);\n\n\t\tlet summaries:string[]=[];\n\t\t//only bother doing summarisation if there are candidates which exceed the token count\n\t\tif(queryResult.some(result=>result.pageContent.trim().split(/\\s+/).length>this.targetSummarisedStringTokenCount)){\n\t\t\tawait this.checkSummariserLoaded();\n\t\t\tif(!this.summariser)return;\n\t\t\tsummaries=(await Promise.allSettled(queryResult.map(async result=>{\n\t\t\t\tif(!result.pageContent||typeof result.pageContent!=='string')return '';\n\t\t\t\tif(result.pageContent.trim().split(/\\s+/).length<=this.targetSummarisedStringTokenCount)return result.pageContent;\n\t\t\t\tlet summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices={\n\t\t\t\t\tstart:0,\n\t\t\t\t\tend:result.pageContent.length\n\t\t\t\t};\n\t\t\t\tif(getSummarisableSubstringIndices)Object.assign(summarisableSubstringIndices,getSummarisableSubstringIndices(result.pageContent));\n\t\t\t\tsummarisableSubstringIndices.start=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.start),0,result.pageContent.length);\n\t\t\t\tsummarisableSubstringIndices.end=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.end),0,result.pageContent.length);\n\t\t\t\tlet summarisableSubstring=result.pageContent.substring(summarisableSubstringIndices.start,summarisableSubstringIndices.end);\n\t\t\t\tlet contentBefore=result.pageContent.substring(0,summarisableSubstringIndices.start);\n\t\t\t\tlet contentAfter=result.pageContent.substring(summarisableSubstringIndices.end);\n\t\t\t\tlet wordsWithoutSummarisable=contentBefore.split(/s+/).length+contentAfter.split(/s+/).length;\n\t\t\t\tlet targetSummarisedSubstringTokenCount=Math.max(1,this.targetSummarisedStringTokenCount-wordsWithoutSummarisable);\n\t\t\t\tlet summarisedSubstringArray=await this.summariser?.(summarisableSubstring,<TextGenerationConfig>{\n\t\t\t\t\tmax_length:targetSummarisedSubstringTokenCount\n\t\t\t\t});\n\t\t\t\tlet summarisedSubstring=Array.isArray(summarisedSubstringArray?.[0])?summarisedSubstringArray?.[0]?.[0]:summarisedSubstringArray?.[0];\n\t\t\t\tlet summarisedString=contentBefore+(summarisedSubstring?.summary_text??'').split(/s+/).slice(targetSummarisedSubstringTokenCount).join(' ')+contentAfter;\n\t\t\t\tif(this.DEBUG)console.log('Summarised candidate: '+summarisedString);\n\t\t\t\treturn summarisedString;\n\t\t\t}))).filter(result=>result.status==='fulfilled'&&result.value).map(result=>(result as PromiseFulfilledResult<string>).value);\n\t\t}else{\n\t\t\tsummaries=queryResult.map(result=>result.pageContent);\n\t\t}\n\n\t\tif(!skipRationale){\n\t\t\tlet rankingPromptTemplate=generatePromptTemplate(generateRankingInstruction({\n\t\t\t\tproblemDescription,\n\t\t\t\tsummaries,\n\t\t\t\tcandidatesForFinalSelection,\n\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t}));\n\t\t\tif(this.DEBUG)console.log('Formatted ranking prompt: '+rankingPromptTemplate);\n\t\t\tlet rankingPromptTokens=this.tokeniser.encode(rankingPromptTemplate);\n\t\t\tif(rankingPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Ranking instruction prompt is too long for the tokeniser model');\n\t\t\ttry{\n\t\t\t\tlet rankingArray=await this.generator(rankingPromptTemplate,{\n\t\t\t\t\tmax_new_tokens:this.rankingMaxNewTokens,\n\t\t\t\t\ttemperature:this.rankingTemperature,\n\t\t\t\t\trepetition_penalty:this.rankingRepetitionPenalty,\n\t\t\t\t\tpad_token_id,\n\t\t\t\t\teos_token_id\n\t\t\t\t});\n\t\t\t\tlet ranking=Array.isArray(rankingArray?.[0])?rankingArray?.[0]?.[0]:rankingArray[0];\n\t\t\t\trationale=ranking.generated_text.toString().trim().replace(/(\\*\\*)|(<\\/?s>)|(\\[.*?\\])\\s*/g, '');\n\t\t\t\tif(this.DEBUG)console.log('Generated rationale: '+rationale);\n\t\t\t\tlet rationaleResponseIndex=rationale.indexOf('### Response:');\n\t\t\t\tif(rationaleResponseIndex>=0)rationaleResponseIndex+='### Response:'.length;\n\t\t\t\telse rationaleResponseIndex=0;\n\t\t\t\trationale=rationale.substring(rationaleResponseIndex);\n\t\t\t\t//if(!rationale)throw new Error('No rationale generated');\n\t\t\t}catch(error){\n\t\t\t\tconsole.log(error);\n\t\t\t\trationale='';\n\t\t\t}\n\t\t}\n\n\t\tif(rationale){\n\t\t\tlet identifiers=extractIdentifiersFromRationale(rationale);\n\t\t\tif(this.DEBUG)console.log('Extracted identifiers from rationale: '+identifiers);\n\t\t\tif(identifiers.length>candidatesForFinalSelection)identifiers=identifiers.slice(0,candidatesForFinalSelection);\n\t\t\tselectedCandidates=lodash.compact(identifiers.map(identifier=>findCandidateFromIdentifier({\n\t\t\t\tidentifier,\n\t\t\t\tcandidateIdentifierField,\n\t\t\t\tcandidates\n\t\t\t})));\n\t\t}\n\n\t\tif(!Array.isArray(selectedCandidates)||selectedCandidates.length<candidatesForFinalSelection){\n\t\t\tif(!Array.isArray(selectedCandidates))selectedCandidates=[];\n\t\t\tlet additionalSelectedCandidates=lodash.compact(queryResult.map(result=>{\n\t\t\t\tlet identifier=extractIdentifierFromCandidateDocument({\n\t\t\t\t\tcandidateDocument:result.pageContent,\n\t\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t\t});\n\t\t\t\tif(this.DEBUG)console.log('Extracted identifier from candidate document: '+identifier);\n\t\t\t\treturn findCandidateFromIdentifier({\n\t\t\t\t\tidentifier,\n\t\t\t\t\tcandidateIdentifierField,\n\t\t\t\t\tcandidates\n\t\t\t\t});\n\t\t\t}));\n\t\t\tselectedCandidates.splice(selectedCandidates.length,0,...additionalSelectedCandidates);\n\t\t\tselectedCandidates=lodash.uniq(selectedCandidates).slice(0,candidatesForFinalSelection-selectedCandidates.length);\n\t\t}\n\t\tif(this.DEBUG)console.log('Selected candidates',selectedCandidates);\n\n\t\treturn{\n\t\t\trationale,\n\t\t\tselectedCandidates\n\t\t};\n\t}\n};\n\nexport namespace AICompareCandidates{\n\texport interface LoadArguments{\n\t\tprogressCallback?:ProgressCallback;\n\t\tmodelName?:string;\n\t};\n\n\texport interface SummarisableSubstringIndices{\n\t\tstart:number;\n\t\tend:number;\n\t};\n\n\texport interface CompareArguments<Candidate>{\n\t\tcandidates:Candidate[];\n\t\tproblemDescription:string;\n\t\tgenerateSearchAreasInstruction?:(problemDescription:string)=>string;\n\t\tparseSearchAreasResponse?:(searchAreasResponse:string)=>string;\n\t\tconvertCandidateToDocument?:(convertCandidateToDocumentArguments:ConvertCandidateToDocumentArguments<Candidate>)=>string;\n\t\tcandidatesForInitialSelection?:number;\n\t\tcandidatesForFinalSelection?:number;\n\t\tgenerateRankingInstruction?:(generateRankingInstructionArguments:GenerateRankingInstructionArguments)=>string;\n\t\textractIdentifiersFromRationale?:(rationale:string)=>string[];\n\t\textractIdentifierFromCandidateDocument?:(extractIdentifierFromCandidateDocumentArguments:ExtractIdentifierFromCandidateDocumentArguments)=>string;\n\t\tcandidateIdentifierField?:keyof Candidate;\n\t\tfindCandidateFromIdentifier?:(findCandidateFromIdentifierArguments:FindCandidateFromIdentifierArguments<Candidate>)=>Candidate|null;\n\t\tgetSummarisableSubstringIndices?:(candidateDocument:string)=>SummarisableSubstringIndices;\n\t\tgeneratePromptTemplate?:(prompt:string)=>string;\n\t\tskipRationale?:boolean;\n\t};\n\n\texport interface ConvertCandidateToDocumentArguments<Candidate>{\n\t\tcandidate:Candidate;\n\t\tindex:number;\n\t};\n\n\texport interface ExtractIdentifierFromCandidateDocumentArguments{\n\t\tcandidateDocument:string;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface FindCandidateFromIdentifierArguments<Candidate>{\n\t\tidentifier:string;\n\t\tcandidateIdentifierField:keyof Candidate;\n\t\tcandidates:Candidate[];\n\t};\n\n\texport interface GenerateRankingInstructionArguments{\n\t\tproblemDescription:string;\n\t\tsummaries:string[];\n\t\tcandidatesForFinalSelection:number;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface CompareCandidatesReturn<Candidate>{\n\t\tselectedCandidates:Candidate[],\n\t\trationale:string\n\t};\n};\n\nexport default AICompareCandidates;"],"mappings":"2PAkBA,IAAa,EAAb,cAAyC,CAAU,CAClD,IAAa,EACb,MAAM,GAEN,UAAsC,KACtC,mBAAmB,yBACnB,iBAAsD,KACtD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE7B,WAAsC,KACtC,oBAAoB,6BACpB,kBAAsD,KACtD,uBAAkD,EAAE,CACpD,2BAAiD,KACjD,0BAA0B,IAAI,gBAE9B,SAAwC,KACxC,kBAAkB,2BAClB,gBAAwD,KACxD,qBAAgD,EAAE,CAClD,yBAA+C,KAC/C,wBAAwB,IAAI,gBAE5B,UAAmC,KACnC,mBAAmB,KAAK,mBACxB,iBAAmD,KACnD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE7B,gCAAgC,GAChC,+BAA+B,IAC/B,qCAAqC,IAErC,oBAAoB,GACpB,mBAAmB,IACnB,yBAAyB,IAEzB,iCAAiC,IAEjC,OACC,EAAI,eAAe,GACnB,EAAI,kBAAkB,GACtB,EAAI,iBAAiB,GAGtB,aAAa,CACZ,MAAM,EAAE,CAAC,CAGV,MAAM,cAAc,CACnB,mBACA,YAAU,IAC4D,EAAE,CAAC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AI,EAAY,EAAgC,EAAU,CACvD,KAAK,OAAM,QAAQ,IAAI,yCAAyC,EAAY,CAC5E,EAAY,OAAO,IAA4B,EAAY,EAAY,MAAM,EAAE,EAA4B,EAC9G,EAAmB,EAAO,QAAQ,EAAY,IAAI,GAAY,EAA4B,CACzF,aACA,2BACA,aACA,CAAC,CAAC,CAAC,CAGL,GAAG,CAAC,MAAM,QAAQ,EAAmB,EAAE,EAAmB,OAAO,EAA4B,CACxF,MAAM,QAAQ,EAAmB,GAAC,EAAmB,EAAE,EAC3D,IAAI,EAA6B,EAAO,QAAQ,EAAY,IAAI,GAAQ,CACvE,IAAI,EAAW,EAAuC,CACrD,kBAAkB,EAAO,YACzB,yBAAyB,OAAO,EAAyB,CACzD,CAAC,CAEF,OADG,KAAK,OAAM,QAAQ,IAAI,iDAAiD,EAAW,CAC/E,EAA4B,CAClC,aACA,2BACA,aACA,CAAC,EACD,CAAC,CACH,EAAmB,OAAO,EAAmB,OAAO,EAAE,GAAG,EAA6B,CACtF,EAAmB,EAAO,KAAK,EAAmB,CAAC,MAAM,EAAE,EAA4B,EAAmB,OAAO,CAIlH,OAFG,KAAK,OAAM,QAAQ,IAAI,sBAAsB,EAAmB,CAE7D,CACL,YACA,qBACA,2BA8DH,IAAA,EAAe"}
1
+ {"version":3,"file":"index.mjs","names":["matches:string[]","match:RegExpExecArray|null","selectedCandidates:Candidate[]","summaries:string[]","summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices"],"sources":["../src/index.ts"],"sourcesContent":["import{\n\tenv,\n\tpipeline,\n\tAutoTokenizer,\n\tTextGenerationPipeline,\n\tProgressInfo,\n\tProgressCallback,\n\tSummarizationPipeline,\n\tFeatureExtractionPipeline,\n\tPreTrainedTokenizer,\n\tTextGenerationConfig,\n\tTextGenerationSingle\n}from '@sroussey/transformers';\nimport {MemoryVectorStore} from '@langchain/classic/vectorstores/memory';\nimport {Embeddings} from '@langchain/core/embeddings';\nimport lodash from 'lodash';\nimport jsan from 'jsan';\n\nexport class AICompareCandidates extends Embeddings{\n\treadonly env=env;\n\tDEBUG=true;\n\n\tgenerator:TextGenerationPipeline|null=null;\n\tgeneratorModelName='Xenova/LaMini-GPT-774M';\n\tgeneratorPromise:Promise<TextGenerationPipeline>|null=null;\n\tgeneratorProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tgeneratorProgressCallback:ProgressCallback|null=null;\n\tgeneratorAbortController=new AbortController();\n\n\tsummariser:SummarizationPipeline|null=null;\n\tsummariserModelName='Xenova/distilbart-cnn-12-6';\n\tsummariserPromise:Promise<SummarizationPipeline>|null=null;\n\tsummariserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tsummariserProgressCallback:ProgressCallback|null=null;\n\tsummariserAbortController=new AbortController();\n\n\tembedder:FeatureExtractionPipeline|null=null;\n\tembedderModelName='Xenova/all-MiniLM-L12-v2';\n\tembedderPromise:Promise<FeatureExtractionPipeline>|null=null;\n\tembedderProgressInfo:ProgressInfo=<ProgressInfo>{};\n\tembedderProgressCallback:ProgressCallback|null=null;\n\tembedderAbortController=new AbortController();\n\n\ttokeniser:PreTrainedTokenizer|null=null;\n\ttokeniserModelName=this.generatorModelName;\n\ttokeniserPromise:Promise<PreTrainedTokenizer>|null=null;\n\ttokeniserProgressInfo:ProgressInfo=<ProgressInfo>{};\n\ttokeniserProgressCallback:ProgressCallback|null=null;\n\ttokeniserAbortController=new AbortController();\n\n\tgenerateSearchAreasMaxNewTokens=64;\n\tgenerateSearchAreasTemperature=0.35;\n\tgenerateSearchAreasRepetitionPenalty=1.5;\n\n\trankingMaxNewTokens=64;\n\trankingTemperature=0.35;\n\trankingRepetitionPenalty=1.5;\n\n\ttargetSummarisedStringTokenCount=420;\n\n\tstatic{\n\t\tenv.localModelPath='';\n\t\tenv.allowRemoteModels=true;\n\t\tenv.allowLocalModels=false;\n\t}\n\n\tconstructor(){\n\t\tsuper({});\n\t}\n\t\n\tasync loadGenerator({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.generatorModelName=modelName;\n\t\tif(!this.generatorModelName)throw new Error('Invalid generator model name');\n\t\tif(progressCallback)this.generatorProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.generatorPromise=pipeline('text-generation',this.generatorModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.generatorProgressInfo,progressInfo);\n\t\t\t\treturn this.generatorProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.generatorAbortController.signal\n\t\t});\n\t\tthis.generator=await this.generatorPromise;\n\t\treturn this.generator;\n\t}\n\n\tasync checkGeneratorLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.generatorPromise)this.loadGenerator({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.generator){\n\t\t\ttry{\n\t\t\t\tawait this.generatorPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.generatorPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.generator){\n\t\t\tthis.generatorPromise=null;\n\t\t\tthrow new Error('Unable to load generator');\n\t\t}\n\t}\n\n\tasync abortLoadGenerator(reason?:any){\n\t\tthis.generatorAbortController.abort(reason);\n\t\tthis.generatorAbortController=new AbortController();\n\t}\n\n\tasync loadSummariser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.summariserModelName=modelName;\n\t\tif(!this.summariserModelName)throw new Error('Invalid summariser model name');\n\t\tif(progressCallback)this.summariserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.summariserPromise=pipeline('summarization',this.summariserModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.summariserProgressInfo,progressInfo);\n\t\t\t\treturn this.summariserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.summariserAbortController.signal\n\t\t});\n\t\tthis.summariser=await this.summariserPromise;\n\t\treturn this.summariser;\n\t}\n\n\tasync checkSummariserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.summariserPromise)this.loadSummariser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.summariser){\n\t\t\ttry{\n\t\t\t\tawait this.summariserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.summariserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.summariser){\n\t\t\tthis.summariserPromise=null;\n\t\t\tthrow new Error('Unable to load summariser');\n\t\t}\n\t}\n\n\tasync abortLoadSummariser(){\n\t\tthis.summariserAbortController.abort();\n\t\tthis.summariserAbortController=new AbortController();\n\t}\n\n\tasync loadEmbedder({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.embedderModelName=modelName;\n\t\tif(!this.embedderModelName)throw new Error('Invalid embedder model name');\n\t\tif(progressCallback)this.embedderProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.embedderPromise=pipeline('feature-extraction',this.embedderModelName,{\n\t\t\tdevice:'webgpu',\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.embedderProgressInfo,progressInfo);\n\t\t\t\treturn this.embedderProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.embedderAbortController.signal\n\t\t});\n\t\tthis.embedder=await this.embedderPromise;\n\t\treturn this.embedder;\n\t}\n\n\tasync checkEmbedderLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.embedderPromise)this.loadEmbedder({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.embedder){\n\t\t\ttry{\n\t\t\t\tawait this.embedderPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.embedderPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.embedder){\n\t\t\tthis.embedderPromise=null;\n\t\t\tthrow new Error('Unable to load embedder');\n\t\t}\n\t}\n\n\tasync abortLoadEmbedder(){\n\t\tthis.embedderAbortController.abort();\n\t\tthis.embedderAbortController=new AbortController();\n\t}\n\n\tasync loadTokeniser({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(typeof modelName==='string'&&modelName)this.tokeniserModelName=modelName;\n\t\tif(!this.tokeniserModelName)throw new Error('Invalid tokeniser model name');\n\t\tif(progressCallback)this.tokeniserProgressCallback=progressCallback;\n\t\t//ts-ignore is needed due to frequent error TS2590: Expression produces a union type that is too complex to represent.\n\t\t//@ts-ignore\n\t\tthis.tokeniserPromise=AutoTokenizer.from_pretrained(this.tokeniserModelName,{\n\t\t\tprogress_callback:progressInfo=>{\n\t\t\t\tif(this.DEBUG)console.log(jsan.stringify(progressInfo));\n\t\t\t\tObject.assign(this.tokeniserProgressInfo,progressInfo);\n\t\t\t\treturn this.tokeniserProgressCallback?.(progressInfo);\n\t\t\t},\n\t\t\tabort_signal:this.tokeniserAbortController.signal\n\t\t});\n\t\tthis.tokeniser=await this.tokeniserPromise;\n\t\treturn this.tokeniser;\n\t}\n\n\tasync checkTokeniserLoaded({\n\t\tprogressCallback,\n\t\tmodelName=''\n\t}:AICompareCandidates.LoadArguments=<AICompareCandidates.LoadArguments>{}){\n\t\tif(!this.tokeniserPromise)this.loadTokeniser({\n\t\t\tprogressCallback,\n\t\t\tmodelName\n\t\t});\n\t\tif(!this.tokeniser){\n\t\t\ttry{\n\t\t\t\tawait this.tokeniserPromise;\n\t\t\t}catch(error){\n\t\t\t\tthis.tokeniserPromise=null;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif(!this.tokeniser){\n\t\t\tthis.tokeniserPromise=null;\n\t\t\tthrow new Error('Unable to load tokeniser');\n\t\t}\n\t}\n\n\tasync abortLoadTokeniser(){\n\t\tthis.tokeniserAbortController.abort();\n\t\tthis.tokeniserAbortController=new AbortController();\n\t}\n\n\tasync embedQuery(text:string):Promise<number[]>{\n\t\tawait this.checkEmbedderLoaded();\n\t\treturn Array.from((await this.embedder?.(text,{\n\t\t\tpooling:'mean',\n\t\t\tnormalize:true\n\t\t}))?.data);\n\t}\n\n\tasync embedDocuments(texts:string[]):Promise<number[][]>{\n\t\treturn Promise.all(texts.map(text=>this.embedQuery(text)));\n\t}\n\n\tdefaultGeneratePromptTemplate(prompt:string){\n\t\treturn 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n'+\n\t\t\t'### Instruction:\\n'+\n\t\t\tprompt+\n\t\t\t'\\n\\n### Response:';\n\t}\n\n\tdefaultGenerateSearchAreasInstruction(problemDescription:string){\n\t\treturn 'List the relevant subject areas for the following issues. Limit your response to 100 words.\\nIssues: \"'+problemDescription+'\"';\n\t}\n\n\tdefaultConvertCandidateToDocument<Candidate>({\n\t\tcandidate,\n\t\tindex\n\t}:AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>=<AICompareCandidates.ConvertCandidateToDocumentArguments<Candidate>>{}){\n\t\tlet document='Start of Candidate #'+index;\n\t\tfor(let i in candidate)document+='\\n'+lodash.startCase(i)+': '+(typeof candidate[i]==='object'?jsan.stringify(candidate[i]):String(candidate[i]));\n\t\tdocument+='\\nEnd of Candidate #'+index;\n\t\treturn document;\n\t}\n\n\tdefaultGenerateRankingInstruction({\n\t\tproblemDescription,\n\t\tsummaries,\n\t\tcandidatesForFinalSelection,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.GenerateRankingInstructionArguments=<AICompareCandidates.GenerateRankingInstructionArguments>{}){\n\t\treturn 'Strictly follow these rules:\\n'+\n\t\t\t'1. Rank ONLY the top '+candidatesForFinalSelection+' candidates with one 15-word sentence explaining why\\n'+\n\t\t\t'2. Rank the candidates based on \"'+problemDescription.replace(/(\\r|\\n)/g,' ')+'\"\\n'+\n\t\t\t'3. If unclear, say \"Insufficient information to determine\"\\n\\n'+\n\t\t\t'Candidates:\\n\\n'+summaries.join('\\n\\n')+'\\n\\n'+\n\t\t\t'Format exactly:\\n'+\n\t\t\t'#1. \"Full '+lodash.startCase(candidateIdentifierField)+'\": 15-word explanation\\n'+\n\t\t\t'#2. ...';\n\t}\n\n\tregexIndexOf(text:string,regex:RegExp,startIndex:number){\n \tlet indexInSuffix=text.slice(startIndex).search(regex);\n \treturn indexInSuffix<0?indexInSuffix:indexInSuffix+startIndex;\n\t}\n\n\tdefaultExtractIdentifierFromCandidateDocument({\n\t\tcandidateDocument,\n\t\tcandidateIdentifierField\n\t}:AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments=<AICompareCandidates.ExtractIdentifierFromCandidateDocumentArguments>{}){\n\t\tif(this.DEBUG)console.log(candidateDocument,candidateIdentifierField);\n\t\tlet startCase=lodash.startCase(candidateIdentifierField);\n\t\tlet startIndex=candidateDocument.indexOf(startCase);\n\t\tif(startIndex<0)startIndex=candidateDocument.toLowerCase().indexOf(startCase.toLowerCase());\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex>=0)startIndex+=startCase.length;\n\t\tif(startIndex<0){\n\t\t\tstartIndex=candidateDocument.toLowerCase().indexOf(candidateIdentifierField.toLowerCase());\n\t\t\tif(startIndex>=0)startIndex+=candidateIdentifierField.length;\n\t\t}\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\telse return '';\n\t\tstartIndex=candidateDocument.indexOf(':',startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)startIndex=this.regexIndexOf(candidateDocument,/\\s+/,startIndex);\n\t\tif(this.DEBUG)console.log(startIndex);\n\t\tif(startIndex<0)return '';\n\t\tlet endIndex=candidateDocument.indexOf('\\n',startIndex);\n\t\tif(endIndex<0)endIndex=candidateDocument.length;\n\t\tif(this.DEBUG)console.log(endIndex);\n\t\treturn candidateDocument.substring(startIndex,endIndex).trim();\n\t}\n\n\tdefaultExtractIdentifiersFromRationale(rationale:string){\n\t\tlet regex=/^\\s*#\\s*\\d+\\s*\\.?\\s*\"([^\"]+)\"/gm;\n\t\tlet matches:string[]=[];\n\t\tfor(let match:RegExpExecArray|null;Array.isArray(match=regex.exec(rationale));)if(match[1])matches.push(match[1]);\n\t\treturn matches;\n\t}\n\n\tdefaultFindCandidateFromIdentifier<Candidate>({\n\t\tidentifier,\n\t\tcandidateIdentifierField,\n\t\tcandidates\n\t}:AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>=<AICompareCandidates.FindCandidateFromIdentifierArguments<Candidate>>{}){\n\t\tlet selectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase()===identifier.toLowerCase());\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>String(candidate[candidateIdentifierField]).toLowerCase().includes(identifier.toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\tselectedCandidate=candidates.find(candidate=>identifier.toLowerCase().includes(String(candidate[candidateIdentifierField]).toLowerCase()));\n\t\tif(selectedCandidate)return selectedCandidate;\n\t\t//split by space and find highest number of matches (tie break if it is in same order)\n\t\tlet identifierWords=identifier.split(/\\s+/g);\n\t\tlet selectedCandidates=candidates.map(candidate=>({\n\t\t\tidentifierWordIndices:identifierWords.map(identifierWord=>String(candidate[candidateIdentifierField]).indexOf(identifierWord)),\n\t\t\tcandidate\n\t\t})).sort((a,b)=>{\n\t\t\tlet aCount=lodash.sumBy(a.identifierWordIndices,aElement=>aElement<0?0:1);\n\t\t\tlet bCount=lodash.sumBy(b.identifierWordIndices,bElement=>bElement<0?0:1);\n\t\t\tif(aCount!==bCount)return bCount-aCount;\n\t\t\tif(aCount===0&&bCount===0)return 0;\n\t\t\taCount=0;\n\t\t\tbCount=0;\n\t\t\tfor(let i=0;i<a.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<a.identifierWordIndices.length;++j){\n\t\t\t\t\tif(a.identifierWordIndices[i]<0||a.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(a.identifierWordIndices[i]<a.identifierWordIndices[j])++aCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(let i=0;i<b.identifierWordIndices.length-1;++i){\n\t\t\t\tfor(let j=i+1;j<b.identifierWordIndices.length;++j){\n\t\t\t\t\tif(b.identifierWordIndices[i]<0||b.identifierWordIndices[j]<0)continue;\n\t\t\t\t\tif(b.identifierWordIndices[i]<b.identifierWordIndices[j])++bCount;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bCount-aCount;\n\t\t});\n\t\tif(selectedCandidates[0].identifierWordIndices.some(index=>index>=0))return selectedCandidates[0].candidate;\n\t\treturn null;\n\t}\n\n\tdefaultParseSearchAreasResponse(searchAreasResponse:string){\n\t\tlet searchAreasResponseIndex=String(searchAreasResponse).indexOf('### Response:');\n\t\tif(searchAreasResponseIndex>=0)searchAreasResponseIndex+='### Response:'.length;\n\t\telse searchAreasResponseIndex=0;\n\t\treturn String(searchAreasResponse).substring(searchAreasResponseIndex).trim();\n\t}\n\n\tasync compareCandidates<Candidate>({\n\t\tcandidates,\n\t\tproblemDescription='',\n\t\tgenerateSearchAreasInstruction=this.defaultGenerateSearchAreasInstruction.bind(this),\n\t\tparseSearchAreasResponse=this.defaultParseSearchAreasResponse.bind(this),\n\t\tconvertCandidateToDocument=this.defaultConvertCandidateToDocument.bind(this),\n\t\tcandidatesForInitialSelection=2,\n\t\tcandidatesForFinalSelection=1,\n\t\tgenerateRankingInstruction=this.defaultGenerateRankingInstruction.bind(this),\n\t\textractIdentifiersFromRationale=this.defaultExtractIdentifiersFromRationale.bind(this),\n\t\textractIdentifierFromCandidateDocument=this.defaultExtractIdentifierFromCandidateDocument.bind(this),\n\t\tcandidateIdentifierField=undefined,\n\t\tfindCandidateFromIdentifier=this.defaultFindCandidateFromIdentifier.bind(this),\n\t\tgetSummarisableSubstringIndices,\n\t\tgeneratePromptTemplate=this.defaultGeneratePromptTemplate.bind(this),\n\t\tskipRationale=false\n\t}:AICompareCandidates.CompareArguments<Candidate>=<AICompareCandidates.CompareArguments<Candidate>>{}):Promise<AICompareCandidates.CompareCandidatesReturn<Candidate>|void>{\n\t\tif(!Array.isArray(candidates)||candidates.length<=0)throw new Error('No candidates provided');\n\t\tcandidatesForInitialSelection=lodash.toSafeInteger(candidatesForInitialSelection);\n\t\tif(candidatesForInitialSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tcandidatesForFinalSelection=lodash.toSafeInteger(candidatesForFinalSelection);\n\t\tif(candidatesForFinalSelection<=0)throw new Error('Candidates for initial selection must be a positive integer bigger than 0');\n\t\tif(candidatesForInitialSelection<candidatesForFinalSelection)throw new Error('Candidates for initial selection must be equal or more than candidates for final selection');\n\t\tif(candidatesForInitialSelection>candidates.length)throw new Error('There are '+candidatesForInitialSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(candidatesForFinalSelection>candidates.length)throw new Error('There are '+candidatesForFinalSelection+'candidates for initial selection which is more than the total number of candidates of '+candidates.length);\n\t\tif(!candidateIdentifierField){\n\t\t\tcandidateIdentifierField=Object.keys(candidates[0] as object)[0] as keyof Candidate;\n\t\t\tif(!candidateIdentifierField)throw new Error('No candidate identifier field');\n\t\t}\n\n\t\tlet rationale='';\n\t\tlet selectedCandidates:Candidate[]=[];\n\n\t\tawait this.checkEmbedderLoaded();\n\t\tif(!this.embedder)return;\n\t\tlet candidateDocuments=candidates.map((candidate,index)=>convertCandidateToDocument({\n\t\t\tcandidate,\n\t\t\tindex\n\t\t}));\n\t\tlet vectorStore=await MemoryVectorStore.fromTexts(\n\t\t\tlodash.cloneDeep(candidateDocuments),\n\t\t\tcandidateDocuments.map((document,index)=>index),\n\t\t\tthis\n\t\t);\n\n\t\tlet searchAreasPromptTemplate=generatePromptTemplate(generateSearchAreasInstruction(problemDescription));\n\t\tif(this.DEBUG)console.log('Formatted search areas prompt: '+searchAreasPromptTemplate);\n\t\tawait this.checkTokeniserLoaded();\n\t\tif(!this.tokeniser)return;\n\t\tlet searchAreasPromptTokens=this.tokeniser.encode(searchAreasPromptTemplate);\n\t\tif(searchAreasPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Search areas instruction prompt is too long for the tokeniser model');\n\n\t\tawait this.checkGeneratorLoaded();\n\t\tif(!this.generator)return;\n\t\tlet pad_token_id=this.tokeniser.pad_token_id??this.tokeniser.sep_token_id??0;\n\t\tlet eos_token_id=this.tokeniser.sep_token_id??2;\n\t\tlet searchAreasReplyArray=await this.generator(searchAreasPromptTemplate,{\n\t\t\tmax_new_tokens:this.generateSearchAreasMaxNewTokens,\n\t\t\ttemperature:this.generateSearchAreasTemperature,\n\t\t\trepetition_penalty:this.generateSearchAreasRepetitionPenalty,\n\t\t\tpad_token_id,\n\t\t\teos_token_id\n\t\t});\n\t\tlet searchAreasReply=Array.isArray(searchAreasReplyArray?.[0])?searchAreasReplyArray?.[0]?.[0]:searchAreasReplyArray?.[0];\n\t\tif(!searchAreasReply.generated_text)throw new Error('No generated text for search areas');\n\t\tif(this.DEBUG)console.log('Generated search areas response: '+searchAreasReply.generated_text);\n\t\tlet vectorSearchQuery=parseSearchAreasResponse(Array.isArray(searchAreasReply.generated_text)?searchAreasReply.generated_text.join('\\n\\n'):String(searchAreasReply.generated_text));\n\t\t//generally the first sentence has the greatest relevance to the actual prompt\n\t\t//if(vectorSearchQuery.includes('.'))vectorSearchQuery=vectorSearchQuery.split('.')[0].trim();\n\t\tif(this.DEBUG)console.log('Vector search query: '+vectorSearchQuery);\n\t\tlet queryResult=await vectorStore.similaritySearch(vectorSearchQuery,candidatesForInitialSelection);\n\t\tif(this.DEBUG)console.log('Vector search results: ',queryResult);\n\n\t\tlet summaries:string[]=[];\n\t\t//only bother doing summarisation if there are candidates which exceed the token count\n\t\tif(queryResult.some(result=>result.pageContent.trim().split(/\\s+/).length>this.targetSummarisedStringTokenCount)){\n\t\t\tawait this.checkSummariserLoaded();\n\t\t\tif(!this.summariser)return;\n\t\t\tsummaries=(await Promise.allSettled(queryResult.map(async result=>{\n\t\t\t\tif(!result.pageContent||typeof result.pageContent!=='string')return '';\n\t\t\t\tif(result.pageContent.trim().split(/\\s+/).length<=this.targetSummarisedStringTokenCount)return result.pageContent;\n\t\t\t\tlet summarisableSubstringIndices:AICompareCandidates.SummarisableSubstringIndices={\n\t\t\t\t\tstart:0,\n\t\t\t\t\tend:result.pageContent.length\n\t\t\t\t};\n\t\t\t\tif(getSummarisableSubstringIndices)Object.assign(summarisableSubstringIndices,getSummarisableSubstringIndices(result.pageContent));\n\t\t\t\tsummarisableSubstringIndices.start=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.start),0,result.pageContent.length);\n\t\t\t\tsummarisableSubstringIndices.end=lodash.clamp(lodash.toSafeInteger(summarisableSubstringIndices.end),0,result.pageContent.length);\n\t\t\t\tif(this.DEBUG)console.log(summarisableSubstringIndices);\n\t\t\t\tlet summarisableSubstring=result.pageContent.substring(summarisableSubstringIndices.start,summarisableSubstringIndices.end);\n\t\t\t\tif(this.DEBUG)console.log(summarisableSubstring);\n\t\t\t\tlet contentBefore=result.pageContent.substring(0,summarisableSubstringIndices.start);\n\t\t\t\tlet contentAfter=result.pageContent.substring(summarisableSubstringIndices.end);\n\t\t\t\tlet wordsWithoutSummarisable=contentBefore.split(/s+/).length+contentAfter.split(/s+/).length;\n\t\t\t\tlet targetSummarisedSubstringTokenCount=Math.max(1,this.targetSummarisedStringTokenCount-wordsWithoutSummarisable);\n\t\t\t\tif(this.DEBUG)console.log(wordsWithoutSummarisable,targetSummarisedSubstringTokenCount);\n\t\t\t\tlet summarisedSubstringArray=await this.summariser?.(summarisableSubstring,<TextGenerationConfig>{\n\t\t\t\t\tmax_length:targetSummarisedSubstringTokenCount\n\t\t\t\t});\n\t\t\t\tlet summarisedSubstring=Array.isArray(summarisedSubstringArray?.[0])?summarisedSubstringArray?.[0]?.[0]:summarisedSubstringArray?.[0];\n\t\t\t\tif(this.DEBUG)console.log(summarisedSubstringArray,summarisedSubstring);\n\t\t\t\tlet summarisedString=contentBefore+(summarisedSubstring?.summary_text??'').split(/s+/).slice(targetSummarisedSubstringTokenCount).join(' ')+contentAfter;\n\t\t\t\tif(this.DEBUG)console.log('Summarised candidate: '+summarisedString);\n\t\t\t\treturn summarisedString;\n\t\t\t}))).filter(result=>result.status==='fulfilled'&&result.value).map(result=>(result as PromiseFulfilledResult<string>).value);\n\t\t}else{\n\t\t\tsummaries=queryResult.map(result=>result.pageContent);\n\t\t}\n\n\t\tif(!skipRationale){\n\t\t\tlet rankingPromptTemplate=generatePromptTemplate(generateRankingInstruction({\n\t\t\t\tproblemDescription,\n\t\t\t\tsummaries,\n\t\t\t\tcandidatesForFinalSelection,\n\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t}));\n\t\t\tif(this.DEBUG)console.log('Formatted ranking prompt: '+rankingPromptTemplate);\n\t\t\tlet rankingPromptTokens=this.tokeniser.encode(rankingPromptTemplate);\n\t\t\tif(rankingPromptTokens.length>this.tokeniser.model_max_length)throw new Error('Ranking instruction prompt is too long for the tokeniser model');\n\t\t\ttry{\n\t\t\t\tlet rankingArray=await this.generator(rankingPromptTemplate,{\n\t\t\t\t\tmax_new_tokens:this.rankingMaxNewTokens,\n\t\t\t\t\ttemperature:this.rankingTemperature,\n\t\t\t\t\trepetition_penalty:this.rankingRepetitionPenalty,\n\t\t\t\t\tpad_token_id,\n\t\t\t\t\teos_token_id\n\t\t\t\t});\n\t\t\t\tlet ranking=Array.isArray(rankingArray?.[0])?rankingArray?.[0]?.[0]:rankingArray[0];\n\t\t\t\trationale=ranking.generated_text.toString().trim().replace(/(\\*\\*)|(<\\/?s>)|(\\[.*?\\])\\s*/g, '');\n\t\t\t\tif(this.DEBUG)console.log('Generated rationale: '+rationale);\n\t\t\t\tlet rationaleResponseIndex=rationale.indexOf('### Response:');\n\t\t\t\tif(rationaleResponseIndex>=0)rationaleResponseIndex+='### Response:'.length;\n\t\t\t\telse rationaleResponseIndex=0;\n\t\t\t\trationale=rationale.substring(rationaleResponseIndex);\n\t\t\t\t//if(!rationale)throw new Error('No rationale generated');\n\t\t\t}catch(error){\n\t\t\t\tconsole.log(error);\n\t\t\t\trationale='';\n\t\t\t}\n\t\t}\n\n\t\tif(rationale){\n\t\t\tlet identifiers=extractIdentifiersFromRationale(rationale);\n\t\t\tif(this.DEBUG)console.log('Extracted identifiers from rationale: '+identifiers);\n\t\t\tif(identifiers.length>candidatesForFinalSelection)identifiers=identifiers.slice(0,candidatesForFinalSelection);\n\t\t\tselectedCandidates=lodash.compact(identifiers.map(identifier=>findCandidateFromIdentifier({\n\t\t\t\tidentifier,\n\t\t\t\tcandidateIdentifierField,\n\t\t\t\tcandidates\n\t\t\t})));\n\t\t}\n\n\t\tif(!Array.isArray(selectedCandidates)||selectedCandidates.length<candidatesForFinalSelection){\n\t\t\tif(!Array.isArray(selectedCandidates))selectedCandidates=[];\n\t\t\tlet additionalSelectedCandidates=lodash.compact(queryResult.map(result=>{\n\t\t\t\tlet identifier=extractIdentifierFromCandidateDocument({\n\t\t\t\t\tcandidateDocument:result.pageContent,\n\t\t\t\t\tcandidateIdentifierField:String(candidateIdentifierField)\n\t\t\t\t});\n\t\t\t\tif(this.DEBUG)console.log('Extracted identifier from candidate document: '+identifier);\n\t\t\t\treturn findCandidateFromIdentifier({\n\t\t\t\t\tidentifier,\n\t\t\t\t\tcandidateIdentifierField,\n\t\t\t\t\tcandidates\n\t\t\t\t});\n\t\t\t}));\n\t\t\tselectedCandidates.splice(selectedCandidates.length,0,...additionalSelectedCandidates);\n\t\t\tselectedCandidates=lodash.uniq(selectedCandidates).slice(0,candidatesForFinalSelection-selectedCandidates.length);\n\t\t}\n\t\tif(this.DEBUG)console.log('Selected candidates',selectedCandidates);\n\n\t\treturn{\n\t\t\trationale,\n\t\t\tselectedCandidates\n\t\t};\n\t}\n};\n\nexport namespace AICompareCandidates{\n\texport interface LoadArguments{\n\t\tprogressCallback?:ProgressCallback;\n\t\tmodelName?:string;\n\t};\n\n\texport interface SummarisableSubstringIndices{\n\t\tstart:number;\n\t\tend:number;\n\t};\n\n\texport interface CompareArguments<Candidate>{\n\t\tcandidates:Candidate[];\n\t\tproblemDescription:string;\n\t\tgenerateSearchAreasInstruction?:(problemDescription:string)=>string;\n\t\tparseSearchAreasResponse?:(searchAreasResponse:string)=>string;\n\t\tconvertCandidateToDocument?:(convertCandidateToDocumentArguments:ConvertCandidateToDocumentArguments<Candidate>)=>string;\n\t\tcandidatesForInitialSelection?:number;\n\t\tcandidatesForFinalSelection?:number;\n\t\tgenerateRankingInstruction?:(generateRankingInstructionArguments:GenerateRankingInstructionArguments)=>string;\n\t\textractIdentifiersFromRationale?:(rationale:string)=>string[];\n\t\textractIdentifierFromCandidateDocument?:(extractIdentifierFromCandidateDocumentArguments:ExtractIdentifierFromCandidateDocumentArguments)=>string;\n\t\tcandidateIdentifierField?:keyof Candidate;\n\t\tfindCandidateFromIdentifier?:(findCandidateFromIdentifierArguments:FindCandidateFromIdentifierArguments<Candidate>)=>Candidate|null;\n\t\tgetSummarisableSubstringIndices?:(candidateDocument:string)=>SummarisableSubstringIndices;\n\t\tgeneratePromptTemplate?:(prompt:string)=>string;\n\t\tskipRationale?:boolean;\n\t};\n\n\texport interface ConvertCandidateToDocumentArguments<Candidate>{\n\t\tcandidate:Candidate;\n\t\tindex:number;\n\t};\n\n\texport interface ExtractIdentifierFromCandidateDocumentArguments{\n\t\tcandidateDocument:string;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface FindCandidateFromIdentifierArguments<Candidate>{\n\t\tidentifier:string;\n\t\tcandidateIdentifierField:keyof Candidate;\n\t\tcandidates:Candidate[];\n\t};\n\n\texport interface GenerateRankingInstructionArguments{\n\t\tproblemDescription:string;\n\t\tsummaries:string[];\n\t\tcandidatesForFinalSelection:number;\n\t\tcandidateIdentifierField:string;\n\t};\n\n\texport interface CompareCandidatesReturn<Candidate>{\n\t\tselectedCandidates:Candidate[],\n\t\trationale:string\n\t};\n};\n\nexport default AICompareCandidates;"],"mappings":"2PAkBA,IAAa,EAAb,cAAyC,CAAU,CAClD,IAAa,EACb,MAAM,GAEN,UAAsC,KACtC,mBAAmB,yBACnB,iBAAsD,KACtD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE7B,WAAsC,KACtC,oBAAoB,6BACpB,kBAAsD,KACtD,uBAAkD,EAAE,CACpD,2BAAiD,KACjD,0BAA0B,IAAI,gBAE9B,SAAwC,KACxC,kBAAkB,2BAClB,gBAAwD,KACxD,qBAAgD,EAAE,CAClD,yBAA+C,KAC/C,wBAAwB,IAAI,gBAE5B,UAAmC,KACnC,mBAAmB,KAAK,mBACxB,iBAAmD,KACnD,sBAAiD,EAAE,CACnD,0BAAgD,KAChD,yBAAyB,IAAI,gBAE7B,gCAAgC,GAChC,+BAA+B,IAC/B,qCAAqC,IAErC,oBAAoB,GACpB,mBAAmB,IACnB,yBAAyB,IAEzB,iCAAiC,IAEjC,OACC,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Q,IAAe,GAAG,CAAC,IAAe,KAAK,GAAG,EAAa,IAC/D,eAAe,UAAU,CAAC,MAAM,CAAC,QAAQ,gCAAiC,GAAG,CAC5F,KAAK,OAAM,QAAQ,IAAI,wBAAwB,EAAU,CAC5D,IAAI,EAAuB,EAAU,QAAQ,gBAAgB,CAC1D,GAAwB,EAAE,GAAwB,GAChD,EAAuB,EAC5B,EAAU,EAAU,UAAU,EAAuB,OAE/C,EAAM,CACZ,QAAQ,IAAI,EAAM,CAClB,EAAU,IAIZ,GAAG,EAAU,CACZ,IAAI,EAAY,EAAgC,EAAU,CACvD,KAAK,OAAM,QAAQ,IAAI,yCAAyC,EAAY,CAC5E,EAAY,OAAO,IAA4B,EAAY,EAAY,MAAM,EAAE,EAA4B,EAC9G,EAAmB,EAAO,QAAQ,EAAY,IAAI,GAAY,EAA4B,CACzF,aACA,2BACA,aACA,CAAC,CAAC,CAAC,CAGL,GAAG,CAAC,MAAM,QAAQ,EAAmB,EAAE,EAAmB,OAAO,EAA4B,CACxF,MAAM,QAAQ,EAAmB,GAAC,EAAmB,EAAE,EAC3D,IAAI,EAA6B,EAAO,QAAQ,EAAY,IAAI,GAAQ,CACvE,IAAI,EAAW,EAAuC,CACrD,kBAAkB,EAAO,YACzB,yBAAyB,OAAO,EAAyB,CACzD,CAAC,CAEF,OADG,KAAK,OAAM,QAAQ,IAAI,iDAAiD,EAAW,CAC/E,EAA4B,CAClC,aACA,2BACA,aACA,CAAC,EACD,CAAC,CACH,EAAmB,OAAO,EAAmB,OAAO,EAAE,GAAG,EAA6B,CACtF,EAAmB,EAAO,KAAK,EAAmB,CAAC,MAAM,EAAE,EAA4B,EAAmB,OAAO,CAIlH,OAFG,KAAK,OAAM,QAAQ,IAAI,sBAAsB,EAAmB,CAE7D,CACL,YACA,qBACA,2BA8DH,IAAA,EAAe"}
File without changes
File without changes
File without changes
package/example/README.md CHANGED
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-compare-candidates-example",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "An example for the ai-compare-candidates library",
5
5
  "productName": "AI Compare Candidates Example",
6
6
  "author": "Wilson Foo Yu Kang <wilson.foo@customautosys.com>",
File without changes
File without changes