What is the path to a Spaces directory?

Hi, what is the path to the following directory:

I have the following code in an app.py file:

import os
import streamlit as st
from transformers import AutoTokenizer, LlamaForCausalLM
import torch

model_directory = '/main/model'

if not os.path.exists(model_directory):
    #model = LlamaForCausalLM.from_pretrained('TheBloke/Wizard-Vicuna-13B-Uncensored-HF')
    #tokenizer = AutoTokenizer.from_pretrained('TheBloke/Wizard-Vicuna-13B-Uncensored-HF')
    model = LlamaForCausalLM.from_pretrained(model_directory)
    tokenizer = AutoTokenizer.from_pretrained(model_directory)

st.title('Chat with LlamaForCausalLM Model')

user_input = st.text_input('Type your message', '')

if st.button('Send'):
    inputs = tokenizer(user_input, return_tensors='pt')
    generate_ids = model.generate(inputs.input_ids, max_length=30)
    response = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]

In the above code, I have the path set to /main/model. This path does not exist.

hi @sschet, give your Space setup I guess what you want is to point the the model relative path to app.py, you might want to try model_directory='./model'

Thank you, that worked

1 Like