FlagAI icon indicating copy to clipboard operation
FlagAI copied to clipboard

[Question]: predict_generate_randomsample的参数如何设定?

Open wanglongxingtianxia opened this issue 2 years ago • 2 comments

Description

使用generate.py 调用aquila-7b模型生成的内容质量很差,需要如何调整参数来生成结果?

Alternatives

aquila-7b生成的内容: text is 汽车EDR是什么 lib/python3.9/site-packages/flagai/model/predictor/aquila.py:32: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor). tokens[k, : len(t)] = torch.tensor(t).long() pred is 汽车EDR是什么? # -- Wuliangxuu self.url = 'https://www.edr.eu' self.dtFormat = '%m/%d'

def _getIndexList(self) -> list:
    # -- Wuliangxuu
    response = requests.get(url=self.url + '/engines/edit',
                            headers={'Referer': self.url})
    response = response.json()['results']['edr_vehicles']
    list = [{"url": response['URL'], "number": [res['VEHICLE_TYPE'] for res in response['VEHICLES']]}]
    return list

def _getBasicInfo(self) -> list:
    if not self.engineType:
        self.engineType = 'any'
    resultList = []
    for i in self.url + '/engines/edit?details=true':
        response = requests.get(

wanglongxingtianxia avatar Jun 12 '23 09:06 wanglongxingtianxia

我生成的结果是“在美国没有听证会,都没有任何有效的授权或者备案,直接执行。在国内上市的汽车,需要说明的安全性评价指标都是在2019年发布的,也就是和国内国家法规在这几年达到基本一致。” Aquila-7b是预训练模型,拿来做生成的话肯定效果是没有对话模型aquilachat好的。 aquila-7b每次生成的结果随机,可能有的时候不会太好(这跟训练的预料有关)

BAAI-OpenPlatform avatar Jun 13 '23 02:06 BAAI-OpenPlatform

out = predictor.predict_generate_randomsample(text, out_max_length=200,top_p=0.95) image

ftgreat avatar Jun 13 '23 02:06 ftgreat

你好,我在使用aquila-7b模型的generate.py脚本进行推理会报错: /home/edcuser/.conda/envs/pytorch_cuda117/lib/python3.10/site-packages/flagai/model/layers/atten │ │ tions.py:189 in forward │ │ │ │ 186 │ │ │ │ 187 │ │ if self.config.flash_atten or (self.config.flash_atten_aquila_style and not self │ │ 188 │ │ │ xq = xq.view(bsz, seqlen, 1, self.n_local_heads, self.head_dim) │ │ ❱ 189 │ │ │ keys = keys.view(bsz, seqlen, 1, self.n_local_heads, self.head_dim) │ │ 190 │ │ │ values = values.view(bsz, seqlen, 1, self.n_local_heads, self.head_dim) │ │ 191 │ │ │ qkv = torch.concat([xq, keys, values], dim=2) │ │ 192 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ RuntimeError: shape '[1, 1, 1, 32, 128]' is invalid for input of size 73728 ,请问您知道怎么解决吗

Maxhyl avatar Jun 15 '23 06:06 Maxhyl

你好,我在使用aquila-7b模型的generate.py脚本进行推理会报错: /home/edcuser/.conda/envs/pytorch_cuda117/lib/python3.10/site-packages/flagai/model/layers/atten │ │ tions.py:189 in forward │ │ │ │ 186 │ │ │ │ 187 │ │ if self.config.flash_atten or (self.config.flash_atten_aquila_style and not self │ │ 188 │ │ │ xq = xq.view(bsz, seqlen, 1, self.n_local_heads, self.head_dim) │ │ ❱ 189 │ │ │ keys = keys.view(bsz, seqlen, 1, self.n_local_heads, self.head_dim) │ │ 190 │ │ │ values = values.view(bsz, seqlen, 1, self.n_local_heads, self.head_dim) │ │ 191 │ │ │ qkv = torch.concat([xq, keys, values], dim=2) │ │ 192 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ RuntimeError: shape '[1, 1, 1, 32, 128]' is invalid for input of size 73728 ,请问您知道怎么解决吗

更新下版本试试

ftgreat avatar Jun 19 '23 02:06 ftgreat