How do fix GPT2 Tokenizer error in Langchain map_reduce (LLama2)?
Labels: name: auto:bug, name: area: models

### System Info

I'm using AWS Sagemaker Jumpstart model for Llama2 13b: meta-textgeneration-llama-2-13b-f

On running a Langchain summarize chain with chain_type="map_reduce" I get the below error. Other chain types (refine, stuff) work without issues. I do not have access to https://huggingface.co/ from my environment. Is there a way to set the gpt2 tokenizer in a local dir?

```
parameters = {
        "properties": {
            "min_length": 100,
            "max_length": 1024,
            "do_sample": True,
            "top_p": 0.9,
            "repetition_penalty": 1.03,
            "temperature": 0.8
        }
    }

class ContentHandler(LLMContentHandler):
    content_type = "application/json"
    accepts = "application/json"

    def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes:
        input_str = json.dumps({"inputs": prompt, **model_kwargs})
        print(input_str)
        return input_str.encode("utf-8")

    def transform_output(self, output: bytes) -> str:
        response_json = json.loads(output.read().decode("utf-8"))
        return response_json[0]["generation"]["content"]

content_handler = ContentHandler()

endpoint_name='xxxxxxxxxxxxxxxxxx'

llm=SagemakerEndpoint(
        endpoint_name=endpoint_name,
        region_name="us-east-1",
        model_kwargs=parameters,
        content_handler=content_handler,
        endpoint_kwargs={"CustomAttributes": 'accept_eula=true'}
)

chain = load_summarize_chain(llm, chain_type="map_reduce")
chain.run(docs)
```

Error:

```
File /usr/local/lib/python3.9/site-packages/transformers/tokenization_utils_base.py:1788, in PreTrainedTokenizerBase.from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, **kwargs)
   1782     logger.info(
   1783         f"Can't load following files from cache: {unresolved_files} and cannot check if these "
   1784         "files are necessary for the tokenizer to operate."
   1785     )
   1787 if all(full_file_name is None for full_file_name in resolved_vocab_files.values()):
-> 1788     raise EnvironmentError(
   1789         f"Can't load tokenizer for '{pretrained_model_name_or_path}'. If you were trying to load it from "
   1790         "'https://huggingface.co/models', make sure you don't have a local directory with the same name. "
   1791         f"Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory "
   1792         f"containing all relevant files for a {cls.__name__} tokenizer."
   1793     )
   1795 for file_id, file_path in vocab_files.items():
   1796     if file_id not in resolved_vocab_files:

OSError: Can't load tokenizer for 'gpt2'. 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 'gpt2' is the correct path to a directory containing all relevant files for a GPT2TokenizerFast tokenizer.
```

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Provided above

### Expected behavior

Provided above