We study the relation between semi and fully device independent protocols. As a tool, we use the correspondence between Bell inequalities and dimension witnesses. We present a method for converting the former into the latter and vice versa. This relation provides us with interesting results for both scenarios. First, we find new random number generation protocols with higher bit rates for both the semi and fully device independent cases. As a byproduct, we obtain whole new classes of Bell inequalities and dimension witnesses. Then, we show how optimization methods used in studies on Bell inequalities can be adopted for dimension witnesses.