完整跑通Learning to Compress Prompts with Gist Tokens代码问题记录

论文链接:https://arxiv.org/abs/2304.08467
1、首先下载llama-7b模型,flant5没下载
下载地址:https://huggingface.co/jayelm/llama-7b-gist-1/tree/main
2、按照说明安装环境
pip install -r requirements.txt
3、问题记录
**

问题一:

**
pydantic.errors.PydanticUserError: If you use @root_validator with pre=False (the default) you MUST specify skip_on_failure=True. Note that @root_validator is deprecated and should be replaced with @model_validator.
在这里插入图片描述
原因:pydantic版本不符,需要降级
解决方法:
(1)查看自己的pydantic,我的版本为2.4.2

pip show pydantic

(2)卸载当前pydantic

pip uninstall pydantic

(3)安装新的pydantic

 pip install pydantic==1.10.9

ok,问题解决

问题二
OSError: Can’t load the configuration of ’ --instruction’. If you were trying to load it from ‘https://huggingface.co/models’, make sure you don’t have a local directory with the same name. Otherwise, make sure ’ --instruction’ is the correct path to a directory containing a config.json file

原因:我是一个傻杯
解决方法:将–model_name_or_path jayelm/llama-7b-gist-1里的jayelm/llama-7b-gist-1换成你自己下载的模型的地址,地址一定要对啊?我搞了快一天了,发现地址放错路径了,快要吐血了。

python -m src.compress --model_name_or_path jayelm/llama-7b-gist-1 --base_llama_path llama-7b \
    --instruction "Name the top cities in France that should not be missed. Include the best aspects of each place as well."

接下来就是考验服务器内存的时候了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
下面是使用Apache Commons Compress库进行高效压缩文件夹的Java代码示例: ```java import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.apache.commons.compress.utils.IOUtils; public class FolderCompressionExample { public static void main(String[] args) { String sourceFolderPath = "path/to/source/folder"; String destinationZipFilePath = "path/to/destination/archive.zip"; compressFolder(sourceFolderPath, destinationZipFilePath); } private static void compressFolder(String sourceFolderPath, String destinationZipFilePath) { try (ZipArchiveOutputStream zipOut = new ZipArchiveOutputStream(new FileOutputStream(destinationZipFilePath))) { File sourceFolder = new File(sourceFolderPath); compressFilesRecursively(zipOut, sourceFolder, ""); zipOut.finish(); } catch (IOException e) { e.printStackTrace(); } } private static void compressFilesRecursively(ZipArchiveOutputStream zipOut, File sourceFile, String parentPath) throws IOException { String entryName = parentPath + sourceFile.getName(); ArchiveEntry entry = zipOut.createArchiveEntry(sourceFile, entryName); zipOut.putArchiveEntry(entry); if (sourceFile.isFile()) { try (FileInputStream fis = new FileInputStream(sourceFile)) { IOUtils.copy(fis, zipOut); } zipOut.closeArchiveEntry(); } else if (sourceFile.isDirectory()) { zipOut.closeArchiveEntry(); File[] children = sourceFile.listFiles(); if (children != null) { for (File child : children) { compressFilesRecursively(zipOut, child, entryName + "/"); } } } } } ``` 上述代码使用Apache Commons Compress库创建了一个Zip压缩文件,并递归地将指定文件夹下的所有文件和子文件夹压缩到该Zip文件中。你只需要将`sourceFolderPath`和`destinationZipFilePath`替换为实际的文件夹路径和目标压缩文件路径。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值