CausalNetEmbedding
Extends:
This CausalNetEmbedding provide methods for transform raw tokenized sentence into its single vector representation mixWith: [ StorageMixins, MemCacheMixins, TokenLookUpMixins, ChunkLookUpMixins, WordEmbeddingMixins ])}
Example:
import { causalNetEmbedding } from 'causal-net.representation';
import { termLogger } from 'causal-net.log';
(async ()=>{
const configLink = '../../datasets/WordVec_EN/';
await causalNetEmbedding.connect(configLink, true);
//first time transform will find on storage cache
let vecs = await causalNetEmbedding.transform(['this', 'is', 'test']);
for(let vec of vecs){
termLogger.log({ vec });
}
//second time transform will find on memory cache
vecs = await causalNetEmbedding.transform(['this', 'is', 'test']);
for(let vec of vecs){
termLogger.log({ vec });
}
//return the tensor representing sentence
let sentVec = await causalNetEmbedding.sentenceEncode([ ['this', 'is', 'test'] ]);
sentVec.print();
})().catch(err=>{
console.error(err);
});
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
F: * |
|
public |
MemCache: * |
|
public |
R: * |
|
public |
Storage: * |
|
public |
|
|
public get |
VecSize: * Return veczie in positive number |
|
public |
baseLink: * |
|
public |
description: * |
|
public |
|
|
public |
embeddingSavePath: string |
|
public |
fetch: * |
|
public |
vecsize: * |
Method Summary
Public Methods | ||
public |
async connect(link: URL | FilePath , refresh: boolean ): Promise Load configure of pretrained vector from either local folder or remote server. |
Private Methods | ||
private |
async getDescription(forceFecth: boolean): * This method is called by connect |
|
private |
async query(link: *): * fetch or read configure depends on provied link format |
|
private |
async queryDescription(): Object query the description json |
Public Constructors
public constructor() source
Public Members
public F: * source
public MemCache: * source
public R: * source
public Storage: * source
public TokenChunkIdMapper: * source
public baseLink: * source
public description: * source
public embeddingDescriptionPath: * source
public embeddingSavePath: string source
public fetch: * source
public vecsize: * source
Public Methods
public async connect(link: URL | FilePath , refresh: boolean ): Promise source
Load configure of pretrained vector from either local folder or remote server. After connect, the result is cached for next time init.
Params:
Name | Type | Attribute | Description |
link | URL | FilePath | link to load |
|
refresh | boolean |
|
force to discard local cache |
Return:
Promise |
Private Methods
private async getDescription(forceFecth: boolean): * source
This method is called by connect
Params:
Name | Type | Attribute | Description |
forceFecth | boolean |
|
Return:
* |
private async query(link: *): * source
fetch or read configure depends on provied link format
Params:
Name | Type | Attribute | Description |
link | * |
Return:
* |
private async queryDescription(): Object source
query the description json
Return:
Object | description json object |