Giter VIP home page Giter VIP logo

Comments (4)

vgel avatar vgel commented on June 18, 2024 4

You can export it for use with llama.cpp with export_gguf, but I haven't written a method to read that gguf file back in for HuggingFace use yet.

In the meantime, you should be able to use np.save to save the dataclass as a dictionary, and then reconstitute it that way:

import dataclasses
import numpy as np
...
v = ControlVector.train(...)
np.save("vector.npy", dataclasses.asdict(v))

# later...
v = ControlVector(**np.load("vector.npy", allow_pickle=True).tolist())

Hope this helps!

from repeng.

l1mc avatar l1mc commented on June 18, 2024

Hi @vgel,

Thanks for the helpful insight on saving a control vector for later use. I noticed that you mentioned the ability to export a control vector with export_gguf for use with llama.cpp. Could you provide an example or guide on how to perform this export?

I found a tutorial on How to convert HuggingFace model to GGUF format. However, I found it difficult to apply this method described here in a Jupyter Notebook (for example, the tutorial ipynb you provided).

Thanks!

from repeng.

vgel avatar vgel commented on June 18, 2024

@l1mc

Hi @vgel,

Thanks for the helpful insight on saving a control vector for later use. I noticed that you mentioned the ability to export a control vector with export_gguf for use with llama.cpp. Could you provide an example or guide on how to perform this export?

I found a tutorial on How to convert HuggingFace model to GGUF format. However, I found it difficult to apply this method described here in a Jupyter Notebook (for example, the tutorial ipynb you provided).

Thanks!

Sorry, didn't see this earlier! Once you have a vector trained with (e.g.) vector = ControlVector.train(...), you can simply export it with:

vector.export_gguf("vector.gguf")

If you're running a version with #34 applied, you can also then import the vector back to Python with

vector = ControlVector.import_gguf("vector.gguf")

or you can use it with llama.cpp using the ./main runner:

$ ./main ... --control-vector vector.gguf --control-vector-layer-range 14 26 ...

Hope this helps!

from repeng.

vgel avatar vgel commented on June 18, 2024

Closing this as addressed by #34

from repeng.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.