All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dingtalk.baymax.framework.sdk.mercury.embeddings.BaseEmbedding Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package com.dingtalk.baymax.framework.sdk.mercury.embeddings;

import com.dingtalk.baymax.framework.sdk.mercury.domain.BaseModel;
import com.dingtalk.baymax.framework.sdk.mercury.domain.Document;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 嵌入模型基类
 *
 * @author xiaoxuan.lp
 */
public abstract class BaseEmbedding extends BaseModel {

    public List embedTexts(List texts) {
        List documents = texts.stream().map(text -> {
            Document document = new Document();
            document.setPageContent(text);
            return document;
        }).collect(Collectors.toList());
        return embedDocument(documents);
    }

    /**
     * 用到的模型类型
     *
     * @return
     */
    public abstract String getModelType();

    /**
     * 对文档进行embedding
     *
     * @param documents
     * @return 向量化后的结果
     */
    public abstract List embedDocument(List documents);


    /**
     * 对文本进行embedding (删除了入参中的recommend参数)
     *
     * @param text
     * @return  text经过embedding后生成的向量
     */
    public abstract List embedQuery(String text);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy