Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 70f2645

Browse files
authored
Update README.rst
1 parent e86b6a5 commit 70f2645

File tree

1 file changed

+55
-5
lines changed

1 file changed

+55
-5
lines changed

README.rst

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,60 @@ Gall <https://pages.iai.uni-bonn.de/gall_juergen/>`__\ :sup:`1,3`
1919
**Abstract:** Modern methods for fine-tuning a Vision Transformer (ViT) like Low-Rank Adaptation (LoRA) and its variants demonstrate impressive performance. However, these methods ignore the high-dimensional nature of Multi-Head Attention (MHA) weight tensors. To address this limitation, we propose Canonical Rank Adaptation (CaRA). CaRA leverages tensor mathematics, first by tensorising the transformer into two different tensors; one for projection layers in MHA and the other for feed-forward layers. Second, the tensorised formulation is fine-tuned using the low-rank adaptation in Canonical-Polyadic Decomposition (CPD) form. Employing CaRA efficiently minimizes the number of trainable parameters. Experimentally, CaRA outperforms existing Parameter-Efficient Fine-Tuning (PEFT) methods in visual classification benchmarks such as Visual Task Adaptation Benchmark (VTAB)-1k and Fine-Grained Visual Categorization (FGVC).
2020

2121

22-
Note
23-
****
24-
We are commited to providing thoroughly tested and well-packaged code.
25-
The code will be soon released once the process is completed.
22+
.. image:: https://raw.githubusercontent.com/BonnBytes/CaRA/refs/heads/dev/images/tensorisation.jpg
23+
:width: 100%
24+
:alt: Alternative text
25+
26+
27+
Installation
28+
============
29+
30+
Use `UV <https://docs.astral.sh/uv/>`_ to install the requirements
31+
32+
For CPU based pytorch
33+
34+
.. code:: bash
35+
36+
uv sync --extra cpu
37+
38+
For CUDA based pytorch
39+
40+
.. code:: bash
41+
42+
uv sync --extra cu118
43+
44+
45+
Datasets
46+
=======
47+
48+
In the case of VTAB-1k benchmark, refer to the dataset download instructions from `NOAH <https://github.com/ZhangYuanhan-AI/NOAH>`_. We download the datasets for FGVC benchmark from their respective sources.
49+
50+
Note: Create a ``data`` folder in the root and place the datasets inside this folder.
51+
52+
53+
Pretrained models
54+
=================
55+
Please refer to the download links provided in the paper.
56+
57+
58+
Training
59+
========
60+
For fine-tuning ViT use the following command.
61+
62+
.. code:: bash
63+
64+
export PYTHONPATH=.
65+
python image_classification/vit_cp.py --dataset=<choice_of_dataset> --dim=<rank>
66+
67+
68+
Evaluation
69+
==========
70+
We provide the link for fine-tuned models for each dataset in VTAB-1k benchmark `here <https://uni-bonn.sciebo.de/s/YAtcRDHxdwnBGq7>`_. To reproduce results from the paper, download the model and execute the following command
71+
72+
.. code:: bash
73+
74+
export PYTHONPATH=.
75+
python image_classification/vit_cp.py --dataset=<choice_of_dataset> --dim=<rank> --evaluate=<path_to_model>
2676
2777
2878
Acknowledgments
@@ -38,4 +88,4 @@ The code is built on the implementation of `FacT <https://github.com/JieShibo/PE
3888
:alt: Project Page
3989
.. |Arxiv| image:: https://img.shields.io/badge/OpenReview-Paper-blue
4090
:target: https://openreview.net/pdf?id=vexHifrbJg
41-
:alt: Paper
91+
:alt: Paper

0 commit comments

Comments
 (0)