diff --git a/all.txt b/all.txt new file mode 100644 index 0000000..a41187e --- /dev/null +++ b/all.txt @@ -0,0 +1,33 @@ +Images from television of ten fired her +Home +SWEENEY BIG +WORLD PARTY +Apart from Fedorov, that fellow who gave us the +I beat a heavy +Pleased with the group's healthy sales, Red Rhino allowed the band the luxury of a colour sleeve for their third release, the double A-side, ‘This Boy Can Wait’ and ‘You Should Always Keep In +Whitbread had no formal education and seems to have been the archetypal self-made +Their answers result in the supreme irony of lorry-loads of young men, having scraped +The Society is keeping in close +In this instance we are again studying a very real struggle, with gangs looting, scavenging and turning to organised crime as a means of scraping +But Mr Kaifu is in no mood to let anyone steal his +With me that rings a warning +Like the constable in the story, use any cover to keep your attacker at +Organisers of the biggest air rally in Europe say that military red +Earlier in this chapter ( p. 70 ) striking a realistic +Inevitably, a book such as this harps +The bottom line +Rachel kept in +It took me breath +( James Brown, 20/2/88 who made it Single Of The Week along with The Wedding Present's ‘Nobody's Twisting Your +The achievements are well recorded : the Brabazon airliner, the abortive TSR2 fighter plane and Concorde — the fastest white +The word is much used by his closest adviser, Hernando de Soto, author of ‘The Other Path’ — a celebrated study of Peru's huge and dense informal sector of street vendors, cottage industries and red +But it had been years, even then, since Elvis was top of the Hit Parade, and if all he had to offer the world was slicked-back hair and a sulky pout, the Dead +Not only in Europe, but also in Afghanistan, Africa and East Asia, the Soviet Empire now drew in its +Why not cut the +While the credit- driven Anglo economies draw in their +Old +I call the +The writer often called the +Far from drawing in his +Fokker is negotiating with Lockheed to assemble aircraft in America : this would bring Lockheed back into the commercial business , which it quit in 1981 after losing its +BRINGING HOME THE \ No newline at end of file diff --git a/best_formal.txt b/best_formal.txt new file mode 100644 index 0000000..8f27628 --- /dev/null +++ b/best_formal.txt @@ -0,0 +1,6 @@ +Images from television of ten fired her imagination +Home truths +SWEENEY BIG Cheese +WORLD PARTY animal +Apart from Fedorov, that fellow who gave us the slip +I beat a heavy retreat diff --git a/config/local.json b/config/local.json index 7cf780b..ee9ec40 100644 --- a/config/local.json +++ b/config/local.json @@ -1,10 +1,10 @@ { "allow_loading_dataset_files": true, - "preloaded_dataset_filename": "sample_input.txt", + "preloaded_dataset_filename": "all.txt", "debug": true, "models": { "": null, - + "meta-llama/Llama-3.2-1B-Instruct": null, "meta-llama/Meta-Llama-3-8B": null, "meta-llama/Meta-Llama-3-70B": null, "meta-llama/Meta-Llama-3-8B-Instruct": null, @@ -51,6 +51,6 @@ "facebook/opt-13b": null, "facebook/opt-30b": null }, - "default_model": "", + "default_model": "meta-llama/Llama-3.2-1B-Instruct", "demo_mode": false } diff --git a/corr2false_formal.txt b/corr2false_formal.txt new file mode 100644 index 0000000..e2a8aee --- /dev/null +++ b/corr2false_formal.txt @@ -0,0 +1,8 @@ +Pleased with the group's healthy sales, Red Rhino allowed the band the luxury of a colour sleeve for their third release, the double A-side, ‘This Boy Can Wait’ and ‘You Should Always Keep In Touch +Whitbread had no formal education and seems to have been the archetypal self-made man +Their answers result in the supreme irony of lorry-loads of young men, having scraped together +The Society is keeping in close touch +In this instance we are again studying a very real struggle, with gangs looting, scavenging and turning to organised crime as a means of scraping together +But Mr Kaifu is in no mood to let anyone steal his thunder +With me that rings a warning bell +Like the constable in the story, use any cover to keep your attacker at bay diff --git a/env.yaml b/env.yaml index 7d76b23..3a791a5 100644 --- a/env.yaml +++ b/env.yaml @@ -6,7 +6,8 @@ channels: dependencies: - python=3.12 - pytorch - - pytorch-cuda=11.8 + #- pytorch-cuda=11.8 # Jana: Resolve version conflict with idiom installations + - pytorch-cuda - nodejs - yarn - pip diff --git a/false2corr_formal.txt b/false2corr_formal.txt new file mode 100644 index 0000000..b546d2a --- /dev/null +++ b/false2corr_formal.txt @@ -0,0 +1,9 @@ +Organisers of the biggest air rally in Europe say that military red tape +Earlier in this chapter ( p. 70 ) striking a realistic balance +Inevitably, a book such as this harps on +The bottom line is +Rachel kept in touch +It took me breath away +( James Brown, 20/2/88 who made it Single Of The Week along with The Wedding Present's ‘Nobody's Twisting Your Arm +The achievements are well recorded : the Brabazon airliner, the abortive TSR2 fighter plane and Concorde — the fastest white elephant +The word is much used by his closest adviser, Hernando de Soto, author of ‘The Other Path’ — a celebrated study of Peru's huge and dense informal sector of street vendors, cottage industries and red tape diff --git a/llm_transparency_tool/models/tlens_model.py b/llm_transparency_tool/models/tlens_model.py index 9342308..3963433 100644 --- a/llm_transparency_tool/models/tlens_model.py +++ b/llm_transparency_tool/models/tlens_model.py @@ -126,7 +126,8 @@ def _model(self): tlens_model.set_tokenizer(self.hf_tokenizer, default_padding_side="left") tlens_model.set_use_attn_result(True) - tlens_model.set_use_attn_in(False) + # Jana: auskommentiert, weil colab mit GQA einen Fehler geworfen hat + #tlens_model.set_use_attn_in(False) tlens_model.set_use_split_qkv_input(False) return tlens_model @@ -158,24 +159,24 @@ def batch_size(self) -> int: raise self._run_exception return self._last_run.logits.shape[0] - @typechecked + #@typechecked # Jana: commented out because of colab issues, TODO: in documentation aufnehmen def tokens(self) -> Int[torch.Tensor, "batch pos"]: if not self._last_run: raise self._run_exception return self._last_run.tokens - @typechecked + #@typechecked def tokens_to_strings(self, tokens: Int[torch.Tensor, "pos"]) -> List[str]: return self._model.to_str_tokens(tokens) - @typechecked + #@typechecked def logits(self) -> Float[torch.Tensor, "batch pos d_vocab"]: if not self._last_run: raise self._run_exception return self._last_run.logits @torch.no_grad() - @typechecked + #@typechecked def unembed( self, t: Float[torch.Tensor, "d_model"], @@ -197,13 +198,13 @@ def _get_block(self, layer: int, block_name: str) -> torch.Tensor: # ================= Methods related to the residual stream ================= - @typechecked + #@typechecked def residual_in(self, layer: int) -> Float[torch.Tensor, "batch pos d_model"]: if not self._last_run: raise self._run_exception return self._get_block(layer, "hook_resid_pre") - @typechecked + #@typechecked def residual_after_attn( self, layer: int ) -> Float[torch.Tensor, "batch pos d_model"]: @@ -211,7 +212,7 @@ def residual_after_attn( raise self._run_exception return self._get_block(layer, "hook_resid_mid") - @typechecked + #@typechecked def residual_out(self, layer: int) -> Float[torch.Tensor, "batch pos d_model"]: if not self._last_run: raise self._run_exception @@ -219,14 +220,14 @@ def residual_out(self, layer: int) -> Float[torch.Tensor, "batch pos d_model"]: # ================ Methods related to the feed-forward layer =============== - @typechecked + #@typechecked def ffn_out(self, layer: int) -> Float[torch.Tensor, "batch pos d_model"]: if not self._last_run: raise self._run_exception return self._get_block(layer, "hook_mlp_out") @torch.no_grad() - @typechecked + #@typechecked def decomposed_ffn_out( self, batch_i: int, @@ -238,7 +239,7 @@ def decomposed_ffn_out( processed_activations = self._get_block(layer, "mlp.hook_post")[batch_i][pos] return torch.mul(processed_activations.unsqueeze(-1), self._model.blocks[layer].mlp.W_out) - @typechecked + #@typechecked def neuron_activations( self, batch_i: int, @@ -247,7 +248,7 @@ def neuron_activations( ) -> Float[torch.Tensor, "hidden"]: return self._get_block(layer, "mlp.hook_pre")[batch_i][pos] - @typechecked + #@typechecked def neuron_output( self, layer: int, @@ -257,13 +258,13 @@ def neuron_output( # ==================== Methods related to the attention ==================== - @typechecked + #@typechecked def attention_matrix( self, batch_i: int, layer: int, head: int ) -> Float[torch.Tensor, "query_pos key_pos"]: return self._get_block(layer, "attn.hook_pattern")[batch_i][head] - @typechecked + #@typechecked def attention_output_per_head( self, batch_i: int, @@ -273,7 +274,7 @@ def attention_output_per_head( ) -> Float[torch.Tensor, "d_model"]: return self._get_block(layer, "attn.hook_result")[batch_i][pos][head] - @typechecked + #@typechecked def attention_output( self, batch_i: int, @@ -283,7 +284,7 @@ def attention_output( return self._get_block(layer, "hook_attn_out")[batch_i][pos] @torch.no_grad() - @typechecked + #@typechecked def decomposed_attn( self, batch_i: int, layer: int ) -> Float[torch.Tensor, "pos key_pos head d_model"]: diff --git a/llm_transparency_tool/routes/contributions.py b/llm_transparency_tool/routes/contributions.py index cc6ddcb..03fd8bb 100644 --- a/llm_transparency_tool/routes/contributions.py +++ b/llm_transparency_tool/routes/contributions.py @@ -13,7 +13,7 @@ @torch.no_grad() -@typechecked +#@typechecked def get_contributions( parts: torch.Tensor, whole: torch.Tensor, @@ -53,7 +53,7 @@ def get_contributions( @torch.no_grad() -@typechecked +#@typechecked def get_contributions_with_one_off_part( parts: torch.Tensor, one_off: torch.Tensor, @@ -90,7 +90,7 @@ def get_contributions_with_one_off_part( @torch.no_grad() -@typechecked +#@typechecked def get_attention_contributions( resid_pre: Float[torch.Tensor, "batch pos d_model"], resid_mid: Float[torch.Tensor, "batch pos d_model"], @@ -125,7 +125,7 @@ def get_attention_contributions( @torch.no_grad() -@typechecked +#@typechecked def get_mlp_contributions( resid_mid: Float[torch.Tensor, "batch pos d_model"], resid_post: Float[torch.Tensor, "batch pos d_model"], @@ -143,7 +143,7 @@ def get_mlp_contributions( @torch.no_grad() -@typechecked +#@typechecked def get_decomposed_mlp_contributions( resid_mid: Float[torch.Tensor, "d_model"], resid_post: Float[torch.Tensor, "d_model"], diff --git a/wrong_formal.txt b/wrong_formal.txt new file mode 100644 index 0000000..8bc97e4 --- /dev/null +++ b/wrong_formal.txt @@ -0,0 +1,12 @@ +SWEENEY BIG Cheese +But it had been years, even then, since Elvis was top of the Hit Parade, and if all he had to offer the world was slicked-back hair and a sulky pout, the Dead Loss +Not only in Europe, but also in Afghanistan, Africa and East Asia, the Soviet Empire now drew in its horns +I beat a heavy retreat +Home truths +Why not cut the Mustard +Apart from Fedorov, that fellow who gave us the slip +While the credit- driven Anglo economies draw in their horns +Old chestnut +I call the tunes +The writer often called the tune +Far from drawing in his horns \ No newline at end of file